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.
The Idle Detection API provides a means to detect the user's idle status, active, idle, and locked, specifically, and to be notified of changes to idle status without polling from a script. Native applications and browser extensions use idle detection base user experiences on when a user is interacting with a device.
Hook into the System.Windows.Forms.Application.Idle event to help detect when the user is idle. Note, I said help.... If the user is idle, use System.Diagnostics.Process.GetCurrentProcess ().TotalProcessorTime to determine if the CPU is idle (at least for this process).
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers. The Idle Detection API provides a means to detect the user's idle status, active, idle, and locked, specifically, and to be notified of changes to idle status without polling from a script.
Please Sign up or sign in to vote. A utility class that alerts your code when the application is idle. If you've ever written a GUI (WinForms) application and wanted to periodically run a background process (such as poll a database), or need to log off the user or close a connection after a certain amount of inactivity, this class may be for you.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With