FTP Upload delay

cirollo

Active Member
Licensed User
Longtime User
Hi! I'm having the following problem:

I'm uploading a file via FTP with the following code:

B4X:
If FTPMode="F" Then    'connessione FTP
 TxtLog.Text = "Invio File "& nomefile &Chr(10)&TxtLog.Text
 FTP.UploadFile(sdRoot, nomefile, True, nomefile)
End If

I check this:
B4X:
Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
   If Success = True Then
      ProgressBar1.Progress = ProgressBar1.Progress + 25
   Else
      Log(LastException.Message)
      Msgbox2("Errore nell'Invio!",Main.nomeprog,"","Ok","",LoadBitmap (File.DirAssets, "warning_256.png"))
      ' svuotiamo la DataExp sulle righe dell'ordine
      If nomefile.SubString2(0,6)="ordini" Then
         Dim Reader As TextReader
            Reader.Initialize(File.OpenInput(sdRoot, nomefile))
            Dim line As String
            Dim WhereFields As Map
         Do While line <> Null 
                line = Reader.ReadLine.SubString2(0,16)
            WhereFields.Initialize
            WhereFields.Put("Seriale", line)
            DBUtils.UpdateRecord(SQL1, "Ordini", "DataExp", "NO", WhereFields)
         Loop
      'Else 'svuotiamo dagli incassi
      End If
   End If
    'If Success = False Then Log(LastException.Message)
End Sub

Then I need to do this, AFTER the completion of the Upload

B4X:
If FTPMode="F" Then    'connessione FTP
 FTP.Close
End If
ProgressBar1.Progress = 100
Timer1.Initialize("Timer1",4000)
Timer1.Enabled=True
If ProgressBar1.Progress = 100 Then
 File.Delete(sdRoot,fileord)
 File.Delete(sdRoot,fileinc)
End If
Msgbox2("Invio completato!",Main.nomeprog,"","Ok","",LoadBitmap (File.DirAssets, "warning_256.png"))

the problem is that there's no delay (4 seconds) and the files are not deleted because the upload is still alive.

So, how can I put a delay between the end of the upload and the remaing elaborations (from "If ProgressBar1.Progress = 100 Then" to the end)???

Tried a timer object but there's no waiting time?!?!?!
Hope to be clear in explanation
 
Top