Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

.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?

Posted
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.
  • 8 months later...
Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...