Idle Detection in WPF

2020-02-09 11:34发布

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.

Can anyone help me? Thank you so much.

1条回答
ら.Afraid
2楼-- · 2020-02-09 12:03

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

查看更多
登录 后发表回答