views:

165

answers:

2

I have a windows form on the main thread and another thread that does some calculations. I'd like to update the status bar on my form from the work being done in the other thread. What's the best way to do this?

So far everything I've tried just makes things run really slowly. I'm using Visual Studio 2005.

+1  A: 

Make sure that you only update the user interface from the main thread or else you will have problems. You can switch your thread context by calling Invoke. There's a good post here on that.

Rob
+1  A: 

You can send messages to the main thread and get it to update the progress bar, although you then need to check for the messages. You could also do the same sort of thing as a polling function.

Colen