Sign in with Microsoft
Sign in or create an account.


The .NET Framework 4.6 added a new enum type value, RunContinuationsAsynchronously, to the TaskCompletionSource and TaskCreationOptions enums. This value forces tasks to run asynchronously, and this helps to avoid deadlock situations. However, an issue has been discovered where, for some specific kinds of continuations (in particular when Task.WhenAll, Task.WhenAny, or TaskExtensions.Unwrap create the continuations), the option is ignored. Therefore, continuations may still run synchronously.

The following sample shows the problem. If the RunContinuationsAsynchronously value were functioning correctly, the two thread IDs that are printed out would never be the same, because the continuation would always be scheduled onto different threads.

using System;
using System.Threading;
using System.Threading.Tasks;

class Program
static void Main()
var mres = new ManualResetEventSlim();


var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);

var t = Task.WhenAll(tcs.Task);

}, TaskContinuationOptions.ExecuteSynchronously);



There is currently no workaround for this issue. The Microsoft .NET Framework team is working on a solution to include in a future update. 

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

What affected your experience?

Thank you for your feedback!