Skip to content
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

Proposal: IAsyncDisposable.ConfigureAwait(bool continueOnCapturedContext) #27857

Closed
stephentoub opened this issue Nov 8, 2018 · 2 comments
Closed
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.Threading.Tasks
Milestone

Comments

@stephentoub
Copy link
Member

In https://github.com/dotnet/corefx/issues/32684, @jnm2 highlighted that in addition to ConfigureAwait on IAsyncEnumerable<T> (which we approved), we should also have it on IAsyncDisposable, so that you can write:

await using (asyncDisposable.ConfigureAwait(false))
{
    ...
}

Thus, the proposal is to add:

namespace System.Threading.Tasks
{
    public static class TaskExtensions // already exists and is where we put the extension for IAsyncEnumerable
    {
        public static ConfiguredAsyncDisposable ConfigureAwait(this IAsyncDisposable source, bool continueOnCapturedContext));
        ...
    }
}

namespace System.Runtime.CompilerServices
{
    public readonly struct ConfiguredAsyncDisposable
    {
        public ConfiguredValueTaskAwaitable DisposeAsync();
    }
}
@stephentoub stephentoub self-assigned this Jan 23, 2019
@jcouv
Copy link
Member

jcouv commented Jan 23, 2019

Hum, there's a compiler issue here too. await using currently only recognizes DisposeAsync that returns ValueTask. I'll loosen that to allow any awaitable.
Filed dotnet/roslyn#32707 (targeting preview3)

@jcouv
Copy link
Member

jcouv commented Jan 23, 2019

Oops, never mind. It's the same issue we're already tracking (allow pattern-based disposal in async constructs). Tracked by dotnet/roslyn#32316

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Threading.Tasks
Projects
None yet
Development

No branches or pull requests

3 participants