I inherited a VB2010 application that hits a web service every so often. Its working great except once in a while the connection to the web service becomes problematic. Right now the .Timeout for the service is set at 100000 or 100 seconds. What I would like to do is just update a label on the form so that the user knows how long he has to wait for the timeout. Like “Connecting (10s)” or something of the sort. Anyway I tried several timers and they all seem to freeze since it seems everything else is waiting for the connection thread to finish. Is there a way to update my label while the service is attempting to connect?
Share
The reason it’s locked up is likely because this is a WinForm project and you are making the call to the web service from the UI thread. As long as the UI thread is busy, the screen will be locked up. To resolve this, you simply need to make the call to the web service in a separate thread. The easiest way to implement this is by using the
BackgroundWorkercomponent. When you are in the form designer, you’ll see it in your components tool box.