Idle Detection in WPF

Kuriyama Mirai picture Kuriyama Mirai · Apr 25, 2014 · Viewed 7.2k times · Source

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.

Answer

owen79 picture owen79 · Apr 25, 2014

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