C#

C#

Made by DeepSource

Incorrect TaskCompletionSource constructor invoked CS-W1067

Bug risk
Critical
Autofix

The TaskCompletionSource class has 2 constructors. The first one takes in an object, while the second one takes in the TaskCreationOptions enum. However, in this case, an incorrect enum TaskContinuationOptions was supplied causing the wrong constructor, i.e. the one that takes in an object to be invoked. It is recommended that you fix this issue as it is likely going to affect your program's execution.

Bad Practice

var tcs = new TaskCompletionSource<int>(TaskContinuationOptions.RunContinuationsAsynchronously);

Recommended

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

Reference