Nikhil
Nikhil

Reputation: 1151

Silverlight tcp socket never calls back the second time, unless I put a breakpoint on the connectasync call

I have a method that attempts to connect. I'm currently testing connection failure. If it fails, the user is offered a retry button. If I press it, m_tcpSocket.ConnectAsync(m_connectArgs); is called again, but I never get a callback.

However, if I put a breakpoint at the ConnectAsync call, the callback will occur.

Is there some cleanup I need to explicitly do that is done automatically when a breakpoint is hit in visual studio?

Thank you.

-Nick

Upvotes: 1

Views: 166

Answers (1)

AnthonyWJones
AnthonyWJones

Reputation: 189555

The Completed event on the SocketAsyncEventArgs is not always called. You sould check the boolean return value of your call to ConnectAsync.

A false value indicates that the connection request has completed synchronously, the properties on the SocketAsyncEventArgs will be ready for inspection and the Completed event will not fire.

Upvotes: 1

Related Questions