Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle client disconnect with PollingDuplexHttpBinding

I am implementing a WCF service, with a Silverlight 3 client, which uses a PollingDuplexHttpBinding for communications. 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?

Thanks.

like image 887
Sako73 Avatar asked Dec 01 '25 04:12

Sako73


1 Answers

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.

like image 155
Ken Smith Avatar answered Dec 03 '25 07:12

Ken Smith