B4J Question Download Progress for two files in row...

Magma

Expert
Licensed User
Longtime User
Hi there...

found this and working for one file..

now tried to download two files in row...
I want to have to downloadprogress in the same sub... files downloading ok.. but second download not show the progress...

B4X:
        Wait For (DownloadAndTrackProgress("https://www.mysite.com/myfile.ver", "myfile.ver")) Complete (Success1 As Boolean)
        If Success1 Then
          
             
                ProgressBar1.Progress=0
              
                      
                Wait For (DownloadAndTrackProgress("https://www.mysite.com/mysecondfile.txt", "mysecondfile.txt")) Complete (success As Boolean)
                If success Then
...

Thought if "success" was different will be ok... but it is not the problem... seems that second time in row - can't get "taskid"... but why ?

Anyone can help ?
 
Solution
Hi there...

Thought if "success" was different will be ok... but it is not the problem... seems that second time in row - can't get "taskid"... but why ?

Anyone can help ?
Yes, you can't get taskid at 2nd time, doing TaskToJob is delayed, so you need add a TaskToJob.Size test in DownloadAndTrackProgress sub

B4X:
Private Sub DownloadAndTrackProgress (url As String, sFile As String) As ResumableSub
......
    Dim TaskToJob As Map = HttpUtils2Service.TaskIdToJob
    Do While HttpUtils2Service.TaskIdToJob.IsInitialized = False or TaskToJob.Size = 0
        Sleep(30)
    Loop
......
End Sub

teddybear

Active Member
Licensed User
Hi there...

Thought if "success" was different will be ok... but it is not the problem... seems that second time in row - can't get "taskid"... but why ?

Anyone can help ?
Yes, you can't get taskid at 2nd time, doing TaskToJob is delayed, so you need add a TaskToJob.Size test in DownloadAndTrackProgress sub

B4X:
Private Sub DownloadAndTrackProgress (url As String, sFile As String) As ResumableSub
......
    Dim TaskToJob As Map = HttpUtils2Service.TaskIdToJob
    Do While HttpUtils2Service.TaskIdToJob.IsInitialized = False or TaskToJob.Size = 0
        Sleep(30)
    Loop
......
End Sub
 
Upvote 0
Solution

Magma

Expert
Licensed User
Longtime User
Yes, you can't get taskid at 2nd time, doing TaskToJob is delayed, so you need add a TaskToJob.Size test in DownloadAndTrackProgress sub

B4X:
Private Sub DownloadAndTrackProgress (url As String, sFile As String) As ResumableSub
......
    Dim TaskToJob As Map = HttpUtils2Service.TaskIdToJob
    Do While HttpUtils2Service.TaskIdToJob.IsInitialized = False or TaskToJob.Size = 0
        Sleep(30)
    Loop
......
End Sub
Yes !!! That was the prob! (the time I was uploading the project... you ve sent me the solution)

Thanks my friend !
 
Upvote 0
Top