WMI 固有事件。资源

发布于 2024-10-08 07:19:22 字数 402 浏览 0 评论 0原文

我订阅了这样的 USB 插入事件

select * FROM __INSTANCECREATIONEVENT WITHIN 3 WHERE TARGETINSTANCE ISA Win32_DiskDrive

插入 USB 闪存后,它每 3 秒闪烁一次。这是轮询间隔,内部事件通过轮询查询中的对象来工作。现在,我们知道这些类型的事件可能会耗费大量资源。 (设置大于 3 的值有时会阻塞这些事件,并且客户端程序不会收到通知)。

还有其他方法可以做到这一点,这样 USB 就不会一直被扫描吗? 可能有一些外部事件可用吗?

现在我看到的唯一解决方案是在触发上面的事件后取消订阅它并在 __INSTANCEDELETIONEVENT 处理程序中重新订阅它。嗯,虽然删除事件也会轮询磁盘驱动器控制器(

I subscribe to usb inserted event like this

select * FROM __INSTANCECREATIONEVENT WITHIN 3 WHERE TARGETINSTANCE ISA Win32_DiskDrive

After inserting usb flash it blinks every 3 seconds. This is polling interval and intrinsic events work by polling object that's in query. Now, we know these types of events may be resource expensive.
(Putting value greater then 3 sometimes chokes these events and client program doesn't get notified).

Are there other ways to do that, so that usb doesn't get scanned all the time?
May be there some extrinsic events available?

Right now the only solution I see is to unsubscribe from event above once it trigerred and resubscribe to it in __INSTANCEDELETIONEVENT handler. Hm, althought deletionevent will also poll diskdrive controllers(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无所谓啦 2024-10-15 07:19:22

设备通知的另一种机制是 RegisterDeviceNotification,您可以在此处阅读:< a href="http://msdn.microsoft.com/en-us/library/aa363432.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa363432.aspx< /a>

Another mechanism for device notification is RegisterDeviceNotification which you can read about here: http://msdn.microsoft.com/en-us/library/aa363432.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文