Can MessageBox.Show cause cross-thread exceptions?

前端 未结 3 1903
独厮守ぢ
独厮守ぢ 2021-01-06 03:46

Can I call MessageBox.Show on a child thread without worrying about a cross-thread exception? I know the ostensible answer would be \"try it and find out\", wh

3条回答
  •  旧时难觅i
    2021-01-06 04:39

    If you call MessageBox.Show("text") without an owner window you are save. If you call MessageBox.Show like MessageBox.Show(this,"text") specifying the owner window things are different.

    I have seen that in Windows XP you are save but in Windows 7 you will run into a cross-thread exception if the owner window is running in a different thread than the thread from which you call the MessageBox!

提交回复
热议问题