C
Crirus
Hi there!
Fisrt the question: there is a ay to make the DownloadData when I want?
I have a WebClient class
I use myWebClient.DownloadData(remoteUrl) to connect to internet server
All this in a separate thread for asincron pourpose
Anyway, when I try to close the application before DownloadData returned, it
wont stop this thread.
The thread run untill a bool variable is set..but if the thread is not on
Reset state I cant send the Set call, or, even if I call it, the Reset is
next
this is the running function for the thread:
Private Sub start()
Do While True
paused.WaitOne() 'wait on the pause event...
If isCancelled = True Then Exit Do
Try
Dim datas, sData As Byte()
Dim strData As String
'sData = getBytes()
SetHeaders()
datas = wbclient.DownloadData(SERVER_ADDRESS)
'datas = wbclient.UploadData(SERVER_ADDRESS, sData) ' signal
back to the caller that we're done...
strData = Encoding.ASCII.GetString(datas)
Dim responseHeaders As New WebHeaderCollection
responseHeaders = wbclient.Headers()
onResponse.Invoke(datas)
paused.Reset() ' pause the thread...
Catch ex As WebException
onResponseError.Invoke(ex.Message)
paused.Reset() ' pause the thread...
End Try
Loop
End Sub
Fisrt the question: there is a ay to make the DownloadData when I want?
I have a WebClient class
I use myWebClient.DownloadData(remoteUrl) to connect to internet server
All this in a separate thread for asincron pourpose
Anyway, when I try to close the application before DownloadData returned, it
wont stop this thread.
The thread run untill a bool variable is set..but if the thread is not on
Reset state I cant send the Set call, or, even if I call it, the Reset is
next
this is the running function for the thread:
Private Sub start()
Do While True
paused.WaitOne() 'wait on the pause event...
If isCancelled = True Then Exit Do
Try
Dim datas, sData As Byte()
Dim strData As String
'sData = getBytes()
SetHeaders()
datas = wbclient.DownloadData(SERVER_ADDRESS)
'datas = wbclient.UploadData(SERVER_ADDRESS, sData) ' signal
back to the caller that we're done...
strData = Encoding.ASCII.GetString(datas)
Dim responseHeaders As New WebHeaderCollection
responseHeaders = wbclient.Headers()
onResponse.Invoke(datas)
paused.Reset() ' pause the thread...
Catch ex As WebException
onResponseError.Invoke(ex.Message)
paused.Reset() ' pause the thread...
End Try
Loop
End Sub