I have a silverlight client that can call a method in my WCF web service to retrieve values from a database. In the case of a long request, I want to give the user the opportunity to cancel it.
Client side, when the user clicks “Cancel”, I call “.Abort ()” in my WCF instance. However, my WCF service will continue to work, as it does not know that the client is no longer connected.
My question is: is it possible for the WCF service to find out that the client has killed the connection?
I tried to judge the ban on the channel. Closed / error events in my contract method, but they never fire ...
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
internal class MyContract: IMyContract
{
public object QueryDatabase(...)
{
System.ServiceModel.OperationContext.Current.Channel.Faulted += new System.EventHandler(Channel_Faulted);
System.ServiceModel.OperationContext.Current.Channel.Closed += new System.EventHandler(Channel_Faulted);
}
void Channel_Faulted(object sender, System.EventArgs e)
{
}
}
Does anyone know how to do this? Thank!
source
share