HTTP Socket Freezes up

Can anyone help with this? I am starting a download. The download happens perfectly fine. While it is downloading I can get my progress bar to update. Its like the program is freezing up. Not sure what Im doing wrong. Here’s the code in the recieve progress for the http socket. Thanks for the help.

Dim iPercent As Integer = (bytesReceived / totalBytes) * 100
UpdateList("", Str(iPercent)+" %")

if totalBytes = 0 then
UpdateProgressBar.Maximum = 0
UpdateProgressBar.Visible = True
PercentLabel.Visible = True

UpdateProgressBar.Maximum =100
UpdateProgressBar.Value = (bytesReceived/totalBytes)*100
PercentLabel.Visible = True

Could you show us how you are making the http call?

Here it is Greg. Thanks for taking a look.

If sError = “” Then
If Not Downloader.Get(sFromURL, fToFileName, 120) Then
sError = “Failed to download file.”
End If
End If

Looks like you’re using “sync” mode, in this case the socket freezes.

Use event driven mode. Create your own class with base (super) from HTTPSocket/HTTPSecureSocket and add event handlers to it which will do the job.

Or, you can use AddHandler to add event handlers to the exists object of HTTPSocket

Did you set the Yield property of your HTTPSocket to True?

No I did not. Should I do that when the window opens?

You should do it before you do a Get request. If you’re doing a synchronous Get and Yield isn’t True, the socket won’t yield time to other events (like updating a progress bar).

Might be better to just rework things to use async mode, though. (And perhaps switch to using the newer URLConnection while you’re at it.)