August 15, 2016

TaskCompletionSource - Bridging the Gap Between Old and New

In the latest versions of the .NET Framework, asynchronous work is represented by the Task class. A task is similar to a future or promise in other languages. You can create one in many ways the most common being Task.Run(). The result of a task is exposed by the Task.Result property. If the work is complete, then the property immediately returns a value; otherwise, it blocks until the operation is finished. Read more

December 9, 2015

A Short and Easy Introduction to .NET's Task Class

Task.Run You can use Task.Run to schedule a delegate to run on the thread pool. The method returns a new task, and if the work is complete, the result will be available via Task.Result. If not, Task.Result will block until it is complete. 1 2 3 4 5 6 7 8 9 10 11 12 private void button_Click(object sender, EventArgs e) { Task<DateTime> task = Task.Run(() => GetDateTime()); lblDateTime.Text = task. Read more

© Joe Buschmann 2020