WMI 固有事件。资源
我订阅了这样的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设备通知的另一种机制是 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