Does MessageBox.Show() automatically marshall to the UI Thread?

No, it doesn’t Marshal to the UI thread. If you think about it, it wouldn’t be possible for it to do so.

It’s possible to have more than one UI thread in an application. Some programs, such as internet explorer, have many UI threads. Which UI thread would the .Show call pick?

It’s also possible to use MessageBox.Show in an application that has no UI threads. You can very well call this in a Console application and it will work.

MessageBox.Show will show UI on the thread it is called from. If there isn’t already a message pump running on the thread it will setup a temporary one in order to function. It will tear it down after the Show call completes.

Leave a Comment