-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non value returning TaskCompletionSource #17393
Comments
We need formal API proposal. |
@benaadams, thoughts on whether this is still important? If you believe it is, can you please add the API proposal details? If not, can you please close it? Thanks! |
Strange thought I had, added |
Should it be |
Approximately what the change would look like: |
Looks good as proposed. namespace System.Threading.Tasks
{
public class TaskCompletionSource
{
public TaskCompletionSource();
public TaskCompletionSource(object? state);
public TaskCompletionSource(TaskCreationOptions creationOptions);
public TaskCompletionSource(object? state, TaskCreationOptions creationOptions);
public Task Task { get; }
public void SetCanceled();
public void SetException(IEnumerable<Exception> exceptions);
public void SetException(Exception exception);
public void SetResult();
public bool TrySetCanceled();
public bool TrySetCanceled(CancellationToken cancellationToken);
public bool TrySetException(IEnumerable<Exception> exceptions);
public bool TrySetException(Exception exception);
public bool TrySetResult();
}
} |
TaskCompletionSource<TResult>
is an easy to use class to use for deferred result returning Tasks controlled via user code; with coverage for exception and cancellation handling.However it would be good to have a non-result returning, non-generic version also e.g.
TaskCompletionSource
withTrySetResult
=>TrySetCompleted
I often see
TaskCompletionSource<object>
withTrySetResult(null)
used for this purpose, however that is not very clean.The text was updated successfully, but these errors were encountered: