Skip to content

fresky/IdleMonitor

Repository files navigation

#IdleMonitor

This is an example code to check if the application has been inactive for a given time.

###IdleMonitor abstract class

The interface is defined in the abstract class IdleMonitor like below.

	public abstract class IdleMonitor
	{
		...
		public event EventHandler TimeoutEventHandler;
		protected IdleMonitor(TimeSpan timeout){...}
		public abstract void Start();
		public abstract void Stop();
		...
	}

In the WinForm or WPF application, it can just create one IdelMonitor from IdleMonitorFactory, then call the Start() to start the Idle Monitor, and call the Stop() to stop the IdleMonitor. The application can add event handler to TimeoutEventHandler, when the timeout reached, the event handler will be called.

Idle Monitor implementation

GetlastInputInfoIdleMonitor

Using the GetlastInputInfo API. It works for WinForm and WPF. #####MessageFilterIdleMonitor Using the MessageFilter, here is List_Of_Windows_Messages. It works for WinForm and WPF. #####ComponentDispatcherIdleMonitor Using the Operationposted and ThreadIdle. It works only for WPF.

WinForm and WPF Example

The WinForm and WPF examples are also included.

About

This is a example code to check if the application has been inactive for a given time.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages