空闲状态检测silverlight 4应用程序
检测 silverlight 应用程序空闲状态的最佳方法是什么?我已经在网上阅读了很多文章,通常它们都是针对 wpf/移动应用程序等。
我创建了一个 DispatcherTimer,它会在 5 分钟后锁定屏幕,似乎我必须转到每个窗口中的每个小部件。 screen(我的应用程序有大约 4-5 个屏幕)并添加 mousebuttondown 或 mouseenter 事件处理程序来重置此计时器。这似乎效率不高,但仅将处理程序添加到layroot 也没有帮助。
有什么有用的建议吗?
谢谢
What's the best way to detect idle state for a silverlight application? I have read quite a few articles on the net by now and usually they are either for wpf/mobile apps etc.
I have created a DispatcherTimer which locks the screen after 5 minutes and it seems that I will have to go to every widget in every screen(my application has around 4-5 screens) and add a mousebuttondown or mouseenter eventhandler to reset this timer. This doesn't seem to be efficient but just adding the handler to the layroot is not helping either.
Any helpful suggestions?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要修改每个控件。如果您在启动时添加以下代码:
使用以下事件处理程序:
其中
idle
是您在DispatcherTimer
Tick
事件中使用的要检查的变量事情是否发生。当事件在树中冒泡时,这应该适用于您的所有控件。
You don't need to modify every control. If you add the following code on startup:
With the following event handlers:
Where
idle
is the variable you use in yourDispatcherTimer
Tick
event to check if things are happening or not.As events bubble up the tree this should work for all your controls.
处理的事件不会冒泡到根控件。相反,您应该使用带有
handledEventsToo = true
的AddHandler
方法。Handled events will not bubble up to root control. Instead you should use the
AddHandler
method withhandledEventsToo = true
.