WPF 中的空闲检测

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23286766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 11:37:50  来源:igfitidea点击:

Idle Detection in WPF

c#wpfidle-timer

提问by Kuriyama Mirai

I'm new in using WPF so I have no Idea how to detect Idle time and show the main window after 5mins of Idle.

我是使用 WPF 的新手,所以我不知道如何检测空闲时间并在空闲 5 分钟后显示主窗口。

Can anyone help me? Thank you so much.

谁能帮我?非常感谢。

采纳答案by owen79

You can do;

你可以做;

var timer = new DispatcherTimer
    (
    TimeSpan.FromMinutes(5),
    DispatcherPriority.ApplicationIdle,// Or DispatcherPriority.SystemIdle
    (s, e) => { mainWindow.Activate(); }, // or something similar
    Application.Current.Dispatcher
    );

picked up from here

这里拿起