- I don't know much about Windows Message Pump but I guess events are triggered using Message Pump.
When my Web browser control navigates to some websites it fires various events of Document Completion. Once I have what I need in WebBrowser_Document_Completed() I want to ignore all further Document Completion.
- How can I it?
If I show a MessageBox() in Document_Completed(...), It shows multiple message boxes, looks like it is running in parallel threads, but when I debug it I find that it runs always on main thread.
- When are the other two threads created?
Also, when I press Close it closes the window but the process is still running in the background. I am not using any other thread yet I still see two other threads when I debug.
Thread.CurrentThread.ManagedThreadId
in messagebox to confirm that really they are different threads. – GildeaMessageBox.Show
or something modal, winforms will internally dispatches the message queue and processes the messages, eventually some message in the queue caused the same main thread to again invoke theDocumentCompleted
event(even when you're still on the MessageBox.Show). Reentracy is somewhat like recursion, but the difference is you didn't called the method yourself as opposed to recursion(you call it deliberately). Same like Application.DoEvents – Gildea