简体   繁体   English

如何使用PollingDuplexHttpBinding处理客户端断开连接

[英]How to handle client disconnect with PollingDuplexHttpBinding

I am implementing a WCF service, with a Silverlight 3 client, which uses a PollingDuplexHttpBinding for communications. 我正在使用Silverlight 3客户端实现WCF服务,该客户端使用PollingDuplexHttpBinding进行通信。 What are the alternatives for handling when a client closes their browser without disconnecting from the server first? 当客户端首先关闭浏览器而不断开与服务器的连接时,有哪些替代方法可以处理?

I know that it will eventually throw a TimeoutException, which I can catch, but is there a better way of detecting this? 我知道它最终会抛出一个TimeoutException,我可以捕获它,但有没有更好的方法来检测它?

Thanks. 谢谢。

You'll want something like this: 你会想要这样的东西:

OperationContext.Current.Channel.Closed += new EventHandler(Channel_Closed);

The channel also exposes a Faulted event, but the Closed event is thrown immediately afterwards. 该频道还会公开Faulted事件,但之后会立即抛出Closed事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM