TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

Control.BeginInvoke versus Control.Invoke

Interesting read in one of Ian Griffiths blog entries entitled “What locks are you holding right now?“ I've been using Control.Invoke up to this point, but maybe it's time to re-think that...

You should also avoid making other threads wait for the UI thread to do something. For example, you should prefer Control.BeginInvoke to Control.Invoke. The problem with blocking a worker thread while you wait for the UI thread to do something is that it's very difficult to be sure that the UI thread isn't waiting for your worker thread to do something. For example, consider the call to BeginInvoke in the ReadComplete method.

<Inside Joke>

Note to a couple of my friends over at APS: this is where you get to use the cool words “thead affinity” in a conversation because Windows Forms controls have thread affinity.  :-)

</Inside Joke>


Digg!

posted on Thursday, September 02, 2004 3:25 PM

Feedback

No comments posted yet.