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