10
  1. 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.

  1. 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.

  1. 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.

4

1 回答 1

1

最直接的方法是通过覆盖它的 WndProc() 方法来拦截和评估正在传播到您的控件的消息。通过一点调试器观察,您可以识别与目标事件对应的 wm_message 常量,然后相应地更改执行流程。在 MSDN 网站上有一个很好的例子: https ://msdn.microsoft.com/en-us/library/system.windows.forms.control.wndproc%28v=vs.110%29.aspx?f =255&MSPP错误=-2147217396

要了解您正在查看/查找的消息,请参考: http ://www.pinvoke.net/default.aspx/Constants/WM.html

于 2015-05-19T16:16:53.420 回答