Hi there. In my application I have a loop that makes calls to a website to download data. I'm using a DownloadDataAsynch call with a handler.
I'm making many such calls in a loop. What I'd like to do is, if I have more than a certain number of replies pending, I should pause the loop and let the data handlers run.
How do I do that?
I'm making many such calls in a loop. What I'd like to do is, if I have more than a certain number of replies pending, I should pause the loop and let the data handlers run.
How do I do that?
VB.NET:
Dim DataReader As SqlDataReader = sp_call.ExecuteReader
Dim count As Integer = 0
[COLOR=DarkGreen]
'---------------------------
' loop through results
' get description for
' each item on the list
'---------------------------[/COLOR]
While DataReader.Read()
[COLOR=DarkGreen]' get the item ID[/COLOR]
Dim itemID As String = DataReader(0).ToString
Dim request_string As String
[COLOR=DarkGreen]'get the data for that item[/COLOR]
request_string = [ web request constructed using item no ]
[COLOR=DarkGreen]' create an asynchronous call[/COLOR]
Dim data_downloader As New WebClient
AddHandler data_downloader.DownloadDataCompleted, AddressOf Data_Downloader_complete
data_downloader.DownloadDataAsync(New Uri(request_string), count)
items_pending = items_pending + 1
If items_pending > 50 Then
[ pause until items_pending < 50 ]
End If
End While