Skip to content

Instantly share code, notes, and snippets.

@amoerie
Created January 31, 2026 08:31
Show Gist options
  • Select an option

  • Save amoerie/7f1f34af8012083976c96035da836dc3 to your computer and use it in GitHub Desktop.

Select an option

Save amoerie/7f1f34af8012083976c96035da836dc3 to your computer and use it in GitHub Desktop.
Banning TaskCompletionSource without RunContinuationsAsynchronously
// TaskCompletionSource should be constructed with TaskCreationOptions.RunContinuationsAsynchronously
// to avoid potential synchronization context issues and deadlocks.
// If you explicitly need the default behavior, use TaskCreationOptions.None.
M:System.Threading.Tasks.TaskCompletionSource.#ctor(); Use new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously) or TaskCreationOptions.None if explicitly needed
M:System.Threading.Tasks.TaskCompletionSource.#ctor(System.Object); Use new TaskCompletionSource(state, TaskCreationOptions.RunContinuationsAsynchronously) or TaskCreationOptions.None if explicitly needed
M:System.Threading.Tasks.TaskCompletionSource`1.#ctor(); Use new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously) or TaskCreationOptions.None if explicitly needed
M:System.Threading.Tasks.TaskCompletionSource`1.#ctor(System.Object); Use new TaskCompletionSource<T>(state, TaskCreationOptions.RunContinuationsAsynchronously) or TaskCreationOptions.None if explicitly needed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment