Search

After UdpClient.BeginReceive completion method is called on UdpClient.Close() by Karlo

Closed
as Fixed Help for as Fixed

2
0
Sign in
to vote
Type: Bug
ID: 97299
Opened: 4/3/2005 5:22:34 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
After calling the BeginReceice() method of a UdpClient object, the provided receive callback method is called when data is ready to read.
However, when the UdpClient is closed without having anything received yet, e.g. because the program is being shut down, the receive callback method is also called after returning from the UdpClient.Close() method.
An exception is raised within the callback method when the udp object is being accessed because it's already disposed. To work around this, the program must maintain some kind of flags to avoid accessing the UdpClient object in the callback in this situation.

I haven't checked the same for other communication objects like TcpClient etc. Might be the same there.
Details (expand)
Product Language
English
Version
Community Technology Preview February 2005
Category
Base Class Libraries and APIs
Subcategory
 
Operating System
Windows XP Professional
Steps to Reproduce
In the programs main thread, create a UdpClient instance and use BeginReceive() for asynchronous receiving. In the callback method, provide some kind of tracing to monitor the callbacks.
Do not send anything to the ready-to-receive UdpClient's address, but call the UdpClient.Close() method at some point.
Observe that the callback is entered. Observe that accessing this udp object there causes an exception because the object is already disposed.
Actual Results
The receive callback is entered without anything has been received and with the UdpClient object not being accessible.
Expected Results
Don't call the receive callback in this case. If that's hard to avoid add appropriate comments to the docs so people are aware.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 4/26/2005 at 8:48 PM
Thanks for your comments, we will have this fixed in the final release.
Posted by Microsoft on 4/19/2005 at 3:28 PM
The Microsoft Sub-status is now "Working on solution"
Posted by Karlo on 4/9/2005 at 6:20 AM
I just wanted to add that the same behaviour seems to exist for TcpClient.
Greetings,
Karlo
Posted by Microsoft on 4/7/2005 at 4:18 PM
Hello,

I have verfied that this issue exists and I am assigning this bug to the development team. We will notify you once this issue has been addressed.

Thank you for bringing this issue to our attention.

Daniel Roth
System.Net
Posted by Microsoft on 4/6/2005 at 3:28 PM
Karlo, thank you for submitting this UdpClient issue. It has been assigned to a product team representative who will respond with comments shortly.

Elliot Rapp
Xml Messaging team
Sign in to post a workaround.