Live Chat Icon For mobile
Live Chat Icon

What is the equivalent of the Windows Forms OnIdle event in WPF?

Platform: WPF| Category: Threading

In WPF, you can set something to be run on application idle or system idle using the Dispatcher instance of the UI thread as follows:

[C#]
// First declare the delgate.
public delegate void OneArgDelegate(int weather);

// This is the method that will be called on system idle:
public void UpdateWeather(int weather)
{
...
}

// Schedule the above method for execution in the UI thread on system idle.
tomorrowsWeather.Dispatcher.BeginInvoke(
    System.Windows.Threading.DispatcherPriority.SystemIdle,
    new OneArgDelegate(UpdateUserInterface), 
    weather);

The other dispatcher priority options that are available are:


SystemIdle,
ApplicationIdle,
ContextIdle,
Background,
Input,
Loaded,
Render,
DataBind,
Normal,
Send

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.