Running progress indicator in different thread to UI thread

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi All

I have a vb.net 2008 app and I want to display a circular marquee progress
control on top of the main controls whilst the app is connecting to an SQL
server database remotely via a vpn

The circular control needs a value (integer) sent to it every 200ms from a
timer

Is there a way to run the timer and update the control from a
backgroundworker so its is responsive

Regards
Steve
 
Hi Steve,

If we are using a BackgroundWorker. We can perform long actions in its
DoWork event handler. In the event handler, we can set the integer value by
calling worker.ReportProgress() function. After that, in the
ProgressChanged event handle, we can retrieve the value from
e.ProgressPercentage. The ProgressChanged event handle is executed in the
main thread. So that we can update the Controls directly.

You can have a look at the following nice article,
http://vbnotebookfor.net/2007/09/24/how-to-update-controls-using-backgroundw
orker-in-vbnet/

Please let me know if you have any future questions on this. Have a nice
day!

Best regards,
Ji Zhou
Microsoft Newsgroup Support Team
 
Hi Ji

I tried the code example but it doesn't work in my situation

When connecting to a remote database the progress indicator appears OK but
there is no action from it when I am trying a test connection to the Remote
sql server db and the connection is down

In other words, the code in the UI is attempting to connect to sql server
until it times out, which prevents the progress control from updating via
Reportprogress event which doesn't fire until the sqlconnection has timed
out

I think I need to put the sqlconnection on a different thread and just run
the progress control from a timer in the UI thread

I have tried Application.DoEvents at applicable places but no difference

Regards
Steve
 
Back
Top