HTTPSocket using 95% cpu

I’ve just started using an HTTPSocket (classic, not the new framework) in a Windows app. It talks to another app on the same machine that uses SOAP. I finally figured out the SOAP format and am successfully communicating. However, the other app can take a LONG time to reply (hundreds of seconds, sometimes). Currently, my socket is synchronous;

Dim response as string = mySocket.Post(theURL, 5000)

Everything works fine, but my app shows up in Task Manager as using 95% (or more) of the cpu for the duration, until the other app replies. Is this normal for HTTPSockets?

I can probably refactor things to make it asynchronous. A hassle, but if that’s the only way around this I’ll do that.

Thoughts?

Thanks!

I’d use async if you can

Thanks Norman, I guess I’ll bite the bullet and do that.

Paris? I thought you were in Canada. Watch out for high water!

Do mySocket.Yield = True before the Post

I wouldn’t. That uses a call to DoEvents up the background which could make bugs really hard to track down. You’ll be better off wrapping your head around async events as they’re way more efficient and cpu friendly in the long run.

[quote=270111:@Charles Weger]Thanks Norman, I guess I’ll bite the bullet and do that.

Paris? I thought you were in Canada. Watch out for high water![/quote]
We left the day it started raining like mad (by pure coincidence)
When we got home 2 days later we saw reports about the rising levels & 2 days after that the water was up over places we had literally just stood 5 days before
Crazy stuff