Silverlight tcp 套接字永远不会第二次回调,除非我在 connectasync 调用上设置断点
我有一个尝试连接的方法。我目前正在测试连接失败。如果失败,则会向用户提供重试按钮。如果我按下它,m_tcpSocket.ConnectAsync(m_connectArgs);再次被调用,但我从未收到回调。
但是,如果我在 ConnectAsync 调用处放置断点,则会发生回调。
当在 Visual Studio 中命中断点时,是否需要明确执行一些清理工作,这些清理工作会自动完成?
谢谢。
-缺口
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SocketAsyncEventArgs
上的Completed
事件并不总是被调用。您应该检查ConnectAsync
调用的布尔返回值。false
值表示连接请求已同步完成,SocketAsyncEventArgs
上的属性将准备好进行检查,并且Completed
事件不会触发。The
Completed
event on theSocketAsyncEventArgs
is not always called. You sould check the boolean return value of your call toConnectAsync
.A
false
value indicates that the connection request has completed synchronously, the properties on theSocketAsyncEventArgs
will be ready for inspection and theCompleted
event will not fire.