Idle Detection in WPF

前端 未结 1 1753
面向向阳花
面向向阳花 2020-12-16 03:08

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条回答
  • 2020-12-16 03:34

    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

    0 讨论(0)
提交回复
热议问题