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?
Okay, here is the requirement. I have some tasks which are done on the UI thread, and I have to show progress on a separate dialog, which is been shown on a worker thread. I understand that it should be the tasks which must be done on worker thread, but the current scenario cannot be changed for the time being.
Every thing is working fine, except for one glitch - if a message box is shown in the UI thread, it gets hidden below the progress dialog. So the user never gets to know that UI is waiting for an input. I need a way to get notified that a modal dialog box has been shown and I should hide the progress dialog.
Right now, I have to hide it explicitly just before every call to MessageBox.
I hope that explains.