-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add CancellationToken overloads to async methods in System.Net.Sockets #19592
Comments
Generaly, I think so: Not All Beginnings Must Have An End |
@EgoPingvina I believe that the ObjectDisposedException is what .Net Framework returns as well. /cc @stephentoub |
@CIPop |
Sorry for missing that: I definitely agree with having new APIs that use The work requires following the API review process. |
@CIPop Yes, you are absolutely right. |
Sounds good. I'm changing this item to track adding CancellationToken in Sockets. |
2 years later and we still don't have a Overload that accepts
|
Duplicate of #921 |
Good day. I work with
UdpClient
and have wrapper upon it.For reading I have asynchronous method:
Where
WithCancellation
is my extension-method for early termination:And after manual reading stop, when I call
Dispose
,System.ObjectDisposedException
occurs.CallStack
:If I understood correctly, root of error in
ReceiveAsync
, in my method of stop it to be exact.After nearly a week of suffering, I have found the reason and solution.
At first, I looked at the
UdpClient
source code. TheReceiveAsync
method:At second, I found this post with perfect answer:http://stackoverflow.com/questions/4662553/how-to-abort-sockets-beginreceive, in which said:
And, as we can see, the original
ReceiveAsync
method return us theObjectDisposedException
, becauseIOOperation
has not been completed afterClose
invoking.To overcome this problem I have done like this:
New
ReceiveAsync
realization:New
Dispose
realization:Is my solution OK(will be cool if you add it to framework in next version) and if not can you say me how to fix it differently?
The text was updated successfully, but these errors were encountered: