The danger of TaskCompletionSource<T> class

… when used with async/await. TaskCompletionSource<T> class is a very useful facility if you want to control the lifetime of a task manually. Here is a canonical example when TaskCompletionSourceis used for converting the event-based asynchronous code to the Task-based pattern: public static Task PerformOperation(this PictureBox pictureBox){    var tcs = new TaskCompletionSource<object>();                // Naive version that does not unsubscribe…

3

Combining iterator blocks and async methods in C#

One of the best traits of a well-designed system is composability. Large systems are complex and hierarchical and one of the best ways to fight accidental complexity is to compose a system from smaller components. You write and test each component independently then you glue them together to achieve a higher-level behavior. Programming languages usually…

0

One user scenario to rule them all

The async series Dissecting the async methods in C#. Extending the async methods in C#. The performance characteristics of the async methods in C#. One user scenario to rule them all. Almost every non-trivial behavior of the async methods in C# can be explained based on one user scenario: migration of the existing synchronous code…

4