The danger of TaskCompletionSource class

added by DotNetKicks
10/1/2018 1:26:09 PM

1380 Views

when used with async/await. TaskCompletionSource 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 (); // Naive version that does not unsubscribe...


0 comments