How do we do idle time processing in WPF application?
It is the Dispatcher.Hooks.DispatcherInactive event.
A late alternative answer (as a memo to myself):
System.Windows.Interop.ComponentDispatcher.ThreadIdle += (_, __) =>
{
Debug.Print("Idle");
};
You can dispatch a task (using the Dispatcher
in the normal way) with a DispatcherPriority
of ApplicationIdle
, which will only be executed when the application is idle. Sample code:
DispatcherPriority priority = DispatcherPriority.ApplicationIdle;
Application.Current.Dispatcher.BeginInvoke(priority, action);