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

March 25, 2015

Async/Await and Recursion

While using the new async/await keywords in C# 5.0 for the first time, I noticed an interesting aspect to how recursive methods behave when using await. For one method I was working on, Resharper notified me of a possible stack overflow exception with a “function is recursive on all paths” warning, but it didn't fail at runtime. Instead, it continued happily calling itself with no issues. What keeps it from failing is the use of the await keyword when calling DoWorkAsync(). Read more

© Joe Buschmann 2020