Do I need to invoke MessageBox calls?

Posted by mafutrct on Stack Overflow See other posts from Stack Overflow or by mafutrct
Published on 2010-05-08T23:59:21Z Indexed on 2010/05/09 0:08 UTC
Read the original article Hit count: 247

Filed under:
|
|

To pop-up a message box, I'm using MessageBox.Show(...). I usually wrap this call in an Invoke:

BeginInvoke (new Action (() => {
    MessageBox.Show ());
}));

I've got 2 questions:

  1. Do I always need to wrap the MessageBox call in an Invoke if I'm calling from a non-GUI thread?

  2. If so, should I use BeginInvoke or Invoke? I found not much difference in my tests, BeginInvoke is, as expected (and unlike Invoke), displayed with a slight delay.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about messagebox