mskeel Posted February 3, 2006 Posted February 3, 2006 .Net 2.0 question. I've got all my heavy operations cranking in a worker thread but I want to display occasional updates to the user through a progress bar in the status strip on my form. The problem is that updating the progress bar from the WorkerThread's update event throws an unsafe update exception becuase the owner of the progress bar is someone other than the thread it is being used from. I found this code to safely update a control across threads, but the status strip version of the progress bar doesn't have the InvokeRequired method. What's another method for safely updating across threads or am I going about this all wrong? Quote
Administrators PlausiblyDamp Posted February 3, 2006 Administrators Posted February 3, 2006 Winforms under .Net 2.0 also has a backgroundworker component (or something like that) - only dabbled with it but it might make your life easier. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mskeel Posted February 3, 2006 Author Posted February 3, 2006 Winforms under .Net 2.0 also has a backgroundworker component (or something like that) - only dabbled with it but it might make your life easier.It certianly did. Dropping that component in helped me clean up a lot of threading code. Now I can handle everything in a few crucial events for the component. This is the only thing that I'm having troubles with using the backgroundWorker component. Everything else has worked like a charm. Quote
mskeel Posted October 24, 2006 Author Posted October 24, 2006 I just found this thread again and realized I never found a good solution. As a work around, I ended up not using the status strip progress bar. Is there a way to do a thread safe update of the status strip progress bar? Because without an InvokeRequired() method, I'm not really sure how to go about this. Maybe throw an event that is caught by the display thread and do the update from there? Quote
Leaders snarfblam Posted October 24, 2006 Leaders Posted October 24, 2006 You can just check Form.InvokeRequired. It will return the same value that a StatusStrip would. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.