Live Chat Icon For mobile
Live Chat Icon

WPF FAQ

Find answers for the most frequently asked questions
Expand All Collapse All

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
Permalink

Share with

Share on twitter
Share on facebook
Share on linkedin

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

Please submit your question and answer.