-
Notifications
You must be signed in to change notification settings - Fork 391
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
C# needs real unit/void support #4102
C# needs real unit/void support #4102
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree it would often be nicer to have a void type that the type system understood.
@@ -71,6 +108,30 @@ protected Task ExecuteUnderLockAsync(Func<CancellationToken, Task> action, Cance | |||
return ExecuteUnderLockCoreAsync(action, cancellationToken); | |||
} | |||
|
|||
private async Task<T> ExecuteUnderLockCoreAsync<T>(Func<CancellationToken, Task<T>> action, CancellationToken cancellationToken = default) | |||
{ | |||
Requires.NotNull(action, nameof(action)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callers already check this. Can remove one or the other.
@@ -71,6 +108,30 @@ protected Task ExecuteUnderLockAsync(Func<CancellationToken, Task> action, Cance | |||
return ExecuteUnderLockCoreAsync(action, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you could merge the two ExecuteUnderLockCoreAsync
methods, keeping only the generic Task<T>
overload and passing a lambda here that produces an ignored return value. Would that introduce significant overhead?
Add Task overloads for downstream consumers (latter PR)