Sunday, April 10, 2011

Quick fire&forget method to delay execution of some code in WPF in C# 4.0

This code will trigger aproximately after 5 seconds and will execute on the UI thread through the dispatcher:



This example uses the Task class introduced with .Net 4.
If you need a more precise way to do it the you should look at the Stopwatch class.

No comments:

Post a Comment