'Called as:
'Wait For(SyncImages) Complete (Result As Object)
'in a chain of WaitFors used to update several items of the local DB
'ImgList contain a list of newer images to download
Sub SyncImages As ResumableSub
Dim remotedir As String = "<my server dir whre images ares tored>"
For i = 0 To ImgList.Size-1
DownloadAndSaveFile (remotedir&ImgList.Get(i), ImgList.Get(i))
Next
Return Null
End Sub
'Download remore image and save it locally
Sub DownloadAndSaveFile (Link As String, fname As String)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Link)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(DBFolder&"/images", fname, False)
File.Copy2(j.GetInputStream, out)
out.Close
End If
j.Release
End Sub
[code]
What do you think? Am I overlooking something basic?