c# - 延迟某个 Action 一段时间

标签 c# multithreading timeout delay execution

我目前正在开发一个屏保启动器,但我想延迟激活屏保一段时间,以确保鼠标位置仍在激活它的位置,以防止意外激活。我正在考虑某种线程在执行前检查鼠标位置 x 秒,这是一个明智的解决方案吗?

I'm not writing a screensaver, I have written an application so that when you move your mouse to a designated corner of your desktop, the screensaver comes on... I want to know how to add a delay to when you move the mouse into that corner to prevent accidental launching of the screensaver

如果是怎么办?

最佳答案

so that when you move your mouse to a designated corner of your desktop, the screensaver comes on...

当鼠标到达那里时,设置一个 bool 值和一个计时器。使任何鼠标操作清除 bool 值。
只有当计时器触发并且您的旗帜仍然存在时,才继续。

换句话说,使用一个小的状态机。

关于c# - 延迟某个 Action 一段时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8650194/

相关文章:

c# - .Net 项目的 TeamCity 增量测试

c++ - 在单独的线程中处理 vector 元素

python - 带有 'with' 语句的非阻塞锁

javascript - 在 AngularJS 单元测试中断言递归 $timeout 中的 http 调用次数

http - 如何用Fiddler模​​拟超时

c# asp.net 下拉列表选择值

c# - WPF:如果转换器的属性发生更改,是否有任何方法可以强制转换器进行更新?

c# - 简单的客户端/服务器,TCP/IP 加密消息流,SSL

c++ - STL映射查找线程安全

asynchronous - 为什么 Future.timeout 在 dart 中不起作用?