المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to know when a Message Box has been shown for a form?



C# Programming
05-29-2009, 04:00 PM
In my application, I have a task which is running on a background thread. I need a notification in the background thread when ever a MessageBox or any modal dialog is displayed in the UI thread.

Though I can do it manually by calling some function before displaying the MessageBox, but it will be great if I dont have to.

For e.g.:

backgroundThread.MessageShown(); // I do not want to call this explicitly every time!
MessageBox.Show("Task halted!");

I am guessing there might me some message which can be hooked on to. Even in the main GUI thread, is there any message/event that get fired just before a modal dialog is shown?

"Do first things first, and second things not at all."
— Peter Drucker.