G
Guest
I have recently implemented asychronous httpwebrequest. My goal in doing
this was to allow me to move my form around while a download was occuring
and to keep the form from being distored when other windows are moved over it
during an httpwebrequest operation. Well, I am running asychronous but I
have not achieved my goals. I have included my code, I hope someone might
give me a suggestion.
Function GetImageFromURL(ByVal url As String) As Byte()
allDone.Reset()
BusyFlag = True
Try
XMainForm.StatusMessage.Clear()
XMainForm.StatusMessage.AppendText("* Loading the file from the server"
Dim wr As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
If Not ProxyObject Is Nothing Then wr.Proxy = ProxyObject
Dim MRS As New RequestState
MRS.request = wr
Dim result As IAsyncResult = CType(wr.BeginGetResponse(AddressOf
RespCallBack, MRS), IAsyncResult)
allDone.WaitOne() 'shouldn't i be able to move my form around while in
wait mode
MRS.response.Close()
XMainForm.StatusMessage.AppendText("* File download complete. Preparing
display.")
BusyFlag = False
Return MRS.ReturnBLOB
Catch MyException As Exception
XMainForm.StatusMessage.AppendText(vbCrLf)
XMainForm.StatusMessage.AppendText(vbCrLf & "* Unable to load the requested
file due to :" & MyException.Message)
End Try
this was to allow me to move my form around while a download was occuring
and to keep the form from being distored when other windows are moved over it
during an httpwebrequest operation. Well, I am running asychronous but I
have not achieved my goals. I have included my code, I hope someone might
give me a suggestion.
Function GetImageFromURL(ByVal url As String) As Byte()
allDone.Reset()
BusyFlag = True
Try
XMainForm.StatusMessage.Clear()
XMainForm.StatusMessage.AppendText("* Loading the file from the server"
Dim wr As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
If Not ProxyObject Is Nothing Then wr.Proxy = ProxyObject
Dim MRS As New RequestState
MRS.request = wr
Dim result As IAsyncResult = CType(wr.BeginGetResponse(AddressOf
RespCallBack, MRS), IAsyncResult)
allDone.WaitOne() 'shouldn't i be able to move my form around while in
wait mode
MRS.response.Close()
XMainForm.StatusMessage.AppendText("* File download complete. Preparing
display.")
BusyFlag = False
Return MRS.ReturnBLOB
Catch MyException As Exception
XMainForm.StatusMessage.AppendText(vbCrLf)
XMainForm.StatusMessage.AppendText(vbCrLf & "* Unable to load the requested
file due to :" & MyException.Message)
End Try