Is there a way to do idle time processing in WPF application equivalent to OnIdle event in MFC?
+4
A:
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.
Jon Skeet
2010-10-06 13:38:42
I have put the code in the constructor and noticed that the task will is executed immediately when we double click the application. I am wondering where do I put my code that will execute whenever my application is not recieving any event or Message q is empty.
Ashish Ashu
2010-10-07 03:17:58
If the code is in the constructor you will want to dispatch the creation of the object (as above with ApplicationIdle priority) as the constructor will always run immediately on creation! Dispatcher.BeginInvoke(new Action(CreateMyObject), DispatcherPriority.ApplicationIdle); Here CreateMyObject is a method that creates your object and Action is the delegate - it can include parameters, see: http://msdn.microsoft.com/en-us/library/018hxwa8.aspx
Mrk Mnl
2010-10-07 03:40:19