Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we do idle time processing in WPF application?

Tags:

c#

.net

wpf

Is there a way to do idle time processing in WPF application equivalent to OnIdle event in MFC?

like image 340
Ashish Ashu Avatar asked Oct 06 '10 13:10

Ashish Ashu


2 Answers

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);
like image 194
Jon Skeet Avatar answered Sep 28 '22 01:09

Jon Skeet


It is the Dispatcher.Hooks.DispatcherInactive event.

like image 24
Oleg Sych Avatar answered Sep 28 '22 01:09

Oleg Sych