简体   繁体   English

WinEventHook:安装事件挂钩的线程结束时会发生什么?

[英]WinEventHook: what happen when the thread that installed the event hook ends?

I did some testing and noticed that when the thread that installed an event hook ends (or is killed) the callback function is no longer called, as if the hook ended together with the thread.我做了一些测试,注意到当安装事件钩子的线程结束(或被杀死)时,不再调用回调函数,就好像钩子与线程一起结束。

However, the documentation says to call UnhookWinEvent from the same thread that installed the event, which is not possible if the thread is no longer alive.但是, 文档说要从安装事件的同一线程调用UnhookWinEvent ,如果线程不再活动,这是不可能的。

Therefore, if the thread that installed the event hook terminates unexpectedly before calling UnhookWinEvent , what happens?因此,如果安装事件挂钩的线程在调用UnhookWinEvent之前意外终止,会​​发生什么情况? Does some problem occur?会不会出现什么问题? Or does the event hook terminate together with the thread, as if UnhookWinEvent had been called?或者事件钩子是否与线程一起终止,就像调用了 UnhookWinEvent 一样?

You probably ought to have read that documentation you linked to:您可能应该已经阅读了您链接到的文档:

If the client's thread ends, the system automatically calls this function.如果客户端的线程结束,系统会自动调用该函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM