I encountered some really weird behaviour with a MessageBox. As mine was a big complex app I thought it could be some complex problem, so I created a really simple app to test the problem, and it is still there. I really do not unstand this behaviour...can
anybody explain it to me!
The simple app that demonstrates the problem is shown below. It is just an empty form with a single timer. The timer event handler invokes a message box. Now I would expect the message box to have modal behaviour, and thus block any further event callbacks
until the dialog is closed. But it didn't, each time the handler is called, a new MessageBox was shown...that's why I added the if(TimerTicks<5) condition ;-)
So at that point I assumed that MessageBox is behaving in a non modal manner for some reason, creating new instances without waiting for button press before returning, and set a breakpoint following the show call to test this (i.e. a breakpoint on 'object
What I found was that this line gets called **after** a dilaog button is pressed, despite the fact that the timer event handler continues to be called at each interval timeout. Whatsmore it gets called every time a dialog is closed, independently from
the regular execution of the handler.