HttpSecureSocket not Yielding

Hi all

Having a bit of trouble understanding synchronous vs asynchronous modes for http(secure)socket

When my desktop app opens, I instantiate (not subclass) a new httpSecureSocket

Dim mySocket As New HTTPSecureSocket mySocket.Yield = True

I then get 3 pieces of data from my website - 3 small text files, just a few kB in size - using 3 separate get methods, with 2 second timeouts

latestVersion = DefineEncoding(mySocket.Get("",2),Encodings.ASCII) newsList = DefineEncoding(mySocket.Get("",2),Encodings.ASCII) blocklist = DefineEncoding(mySocket.Get("",2),Encodings.ASCII)

Then then app accesses a local database and fills out a listbox and continues on its merry way.

My understanding was that by setting mySocket.Yield = true the app would continue to process (i.e. fill the listbox etc) while fetching the 3 text files in the background. However, it does not. The rest of the app does not continue until the 3 get methods are completed.

If I set the timeouts to 10 seconds and turn off internet access on my machine, the app does not continue until 3 x 10 seconds of trying to get are completed.

Setting mySocket.Yield to true or false makes no difference.
What a I missing?

HTTPSecureSocket.Get(URL, Timeout) is synchronous. Use HTTPSecureSocket.Get(URL) or HTTPSecureSocket.Get(URL, FolderItem) for asynchronous transfers. This also means you need to handle the PageReceived (or DownloadComplete) event since async methods don’t return the downloaded data like your code expects.

So whats the point of socket.Yield = true?

I think it allows the event loop and other background tasks to run.

Thanks. Thats not made very clear on the documentation.


The socket may be yielding, but if your code is executing in the main thread, then your code is still blocking the app. Yield is useful in the context of a thread.

When you set Yield to true it just calls DoEvents while its waiting for a response, so it shouldn’t require a thread to yield.

Seriously? Learn something new…