When ever IVideoWindow::put_Visible() is invoked, it peek a message from the message queue and dispatch it. That totally messes up the call sequence.
I have fixed several crashes caused by this, in a case by case bias. That is, to set a flag before invoking put_Visible() and then clean the flag. And in an event-handler, check the flag first, if it is set, put the event back to message queue and exit the event-handler (i.e. postpone the handling until put_Visible() returns. The problem is my code base is too large and that method does not sustain.
Is there a way simply change the behavior of put_Visible() to make it don't mess the message queue and dispatching?