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

Implement IAsyncDisposable and remove ChainedAsyncResult as it's buggy #4865

Merged
merged 3 commits into from
Aug 15, 2022

Conversation

mconnew
Copy link
Member

@mconnew mconnew commented Jul 29, 2022

Fixes #26
Implements the method described here when using DisposeAsync. It will only handle TimeoutException or CommunicationException (or a derived class), but anything outside of those exceptions are being thrown by user code.

The problem with ChainedAsyncResult was that if you threw an exception in an event handler when closing, it would be get wrapped in a CallbackException, but then rethrown in a way where nothing would catch it and the async Close operation would never complete. I verified the replacement code will cause the exception to reach user code.

I also discovered some dead code so removed that.

This also adds CloseAsync to ClientBase<TChannel>.

@mconnew mconnew mentioned this pull request Aug 15, 2022
@mconnew mconnew merged commit a197a75 into dotnet:main Aug 15, 2022
@mconnew mconnew deleted the DisposeAsyncSupport branch October 11, 2023 17:11
0xced added a commit to 0xced/wcf that referenced this pull request Dec 14, 2023
So that channels created through a `ChannelFactory<T>` without inheriting from `ClientBase<T>` can also benefit from the asynchronous disposal improvements introduced in dotnet#4865.

Fixes dotnet#5270
mconnew pushed a commit that referenced this pull request Mar 21, 2024
So that channels created through a `ChannelFactory<T>` without inheriting from `ClientBase<T>` can also benefit from the asynchronous disposal improvements introduced in #4865.

Fixes #5270
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to make Dispose safely dispose of a channel without throwing an exception
2 participants