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

host.DisposeAsync() を待たずに処理が進んでしまう #6

Closed
in-async opened this issue Feb 7, 2020 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@in-async
Copy link
Owner

in-async commented Feb 7, 2020

Task.Run() のデリゲートで ValueTask を返している為:

await Task.Run(() => {
if (host is IAsyncDisposable asyncDisposable) {
return asyncDisposable.DisposeAsync();
}
host.Dispose();
return default;
}).ConfigureAwait(false);

Task を返すようにすれば解決:

 await Task.Run(() => { 
     if (host is IAsyncDisposable asyncDisposable) { 
         return asyncDisposable.DisposeAsync().AsTask(); 
     } 
  
     host.Dispose(); 
     return Task.CompletedTask;
 }).ConfigureAwait(false); 
@in-async in-async self-assigned this Feb 7, 2020
@in-async in-async added the bug Something isn't working label Feb 7, 2020
@in-async
Copy link
Owner Author

in-async commented Feb 7, 2020

ついでに、CancelKeyPress による deadlock 対応はこうしたい:

await Task.Yield();
if (host is IAsyncDisposable asyncDisposable) {
    await asyncDisposable.DisposeAsync().ConfigureAwait(false);
}
else {
    host.Dispose();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant