I have a loop set up that iterates through a List of video object and downloads them one by one. The problem is, that because of varying file sizes, I need my outter loop to wait until a file is downloaded. What would be the most efficient way to do this? I am using System.Net.Webclient
As of right now the downloading works somewhat, I get about 24-27 of 94 files. The download method I am using is synchronous btw.
Now I did throw in a 2 minute sleep method on the main thread and it got all 94 files, but that just doesn't feel right hehehehe :P
I am thinking I could use Asynchronous download from System.Net.Webclient and the Downloaded event to inform myself that the file is completed and I can move onto the next file in the video_list.Entries, but I honestly am not sure how to go about that.
Thank you for your help!
For Each _video As Video In video_list.Entries Dim paramVideo As Video = _video viItem = New VideoInfo count = count + 1 Dim VideoTitle As String = count.ToString() + ": " + _video.Title.ToString() viItem.IndexCount = count.ToString() viItem.Title = _video.Title.ToString() viItem.URL = _video.WatchPage.AbsoluteUri.ToString() _List.Add(viItem) t2 = New Thread(Sub() Me.download(paramVideo, yourequest, count)) t2.Start() 'Need to wait here until t2 is finished downloading then end the thread. Next
View the full article




Sign In
Create Account
Back to top







