-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 2.8.0
-
Component/s: Connectivity
-
None
UpdateClusterDescription in Cluster.cs calls TrySetResult on a TaskCompletionSource.
There is an issue with how TrySetResult works. If there are already other tasks waiting for this result they will execute synchronously in the current thread which means that TrySetResult might not return for a long time depending on how many tasks start to run as a result. We require that TrySetResult return immediately so that we can continue and finish the process of updating the cluster state.
In .NET Framework 4.6.1 we could use the RunContinuationsAsynchronously TaskCreationOptions to specify that TrySetResult should only schedule waiting tasks for asynchronous execution and not run them synchronously, so that TrySetResult returns as quickly as possible.
Since we currently only require .NET Framework 4.5.2 a work around would be:
Task.Run(() => oldDescriptionChangedTaskCompletionSource.TrySetResult(true));
so that TrySetResult itself is called asynchronously from a new Task.
- is related to
-
CSHARP-2573 Use RunContinuationsAsynchronously with TaskCompletionSource
- Closed