|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
New async socket behavior?My company has recently migrated an application from .Net 1.1 to .Net 2.0. It uses the Socket class to perform some network communications. When Calling the BeginConnect() method, I have noticed that sometimes the specified AsyncCallback method will actually get called from the same thread as the BeginConnect() call was made from, prior to the the BeginConnect() call returning (i.e. same thread, same call stack). In .Net 1.1, the callback was always performed on a separate thread. I've even gone back and run some tests to verify this. I guess I would just like some confirmation. Did this behavior change between version 1.1 and 2.0? Is this a bug in .Net 2.0? The documentation for BeginConnect() explicitly states "the system will use a separate thread to execute the specified callback method." This caused an issue in our application that we were able to easily correct, but I wanted to throw this out there in case anyone else is experiencing a similar problem. Thanks! --Darren I've noticed similar behavior in the Async ASP.Net infrastructure, but not
in Sockets. I know that in some of our custom implemented IAsyncResult classes, we hit some strane errors around this - but again, they were all in ASP.Net. Personally, if the runtime is able to eliminate the context switch, I think it's a good thing. I can see where it would be a bit frustrating though to have it happen in an unexpected chunk of code.... -- Show quoteChris Mullins "Darren" <notr***@hotmail.com> wrote in message news:c109bfad-b9cc-4efb-8455-872e7cb21105@o6g2000hsd.googlegroups.com... > Hi all, > > My company has recently migrated an application from .Net 1.1 to .Net > 2.0. It uses the Socket class to perform some network > communications. When Calling the BeginConnect() method, I have > noticed that sometimes the specified AsyncCallback method will > actually get called from the same thread as the BeginConnect() call > was made from, prior to the the BeginConnect() call returning (i.e. > same thread, same call stack). > > In .Net 1.1, the callback was always performed on a separate thread. > I've even gone back and run some tests to verify this. I guess I > would just like some confirmation. Did this behavior change between > version 1.1 and 2.0? Is this a bug in .Net 2.0? The documentation > for BeginConnect() explicitly states "the system will use a separate > thread to execute the specified callback method." > > This caused an issue in our application that we were able to easily > correct, but I wanted to throw this out there in case anyone else is > experiencing a similar problem. > > Thanks! > --Darren |
|||||||||||||||||||||||