In .NET 3.5, is it possible to cancel an asynchronous call to a WCF service ?
The desire is that a user search screen may fire a very long running SQL query in the middle tier, which they then want to cancel. The idea is that the actual database query gets cancelled, not just the WCF call to the middle-tier (otherwise the SQL query is still chewing up resources in the database).ÃÂ Is this possible ?
I'm using the event-based asynchronous pattern that was introduced for WCF in .NET 3.5, which Microsoft are now recommending to be used: http://msdn2.microsoft.com/en-us/library/ms734701.aspx
//hook up Completed handler, and call service asynchronously. Use Tab|Tab to auto-generated in VS
client.SomeMethodCompleted += new EventHandler<SomeMethodCompletedEventArgs>(client_SomeMethodCompleted);
//Asynchronous result - display in UI.
//Completed event handler gets called on UI thread it was created from.
void client_SomeMethodCompleted(object sender, SomeMethodCompletedEventArgs e)
//Do something with e.Result;
View Complete Post