Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can calling Abort() on an IClientChannel proxy throw an exception?

Based on documentation and articles it is recommended to call Abort() on a client proxy if an unexpected exception/fault is encountered. See the following (simplified):

MyServiceClient proxy = null;
try {
    proxy = new MyServiceClient();
    proxy.DoSomething();
    proxy.Close();
} catch (Exception ex) {
    if (proxy != null)
        proxy.Abort();
}

Is there any possibility of the call to Abort() throwing an exception itself? Should the call to Abort() be within its own try/catch?

like image 432
Elan Avatar asked Oct 15 '22 13:10

Elan


1 Answers

No, Abort will not fail (but .Close() or .Dispose() might). Calling .Abort() is the "sledgehammer" approach to terminating a channel - it's just torn down, regardless of an ongoing message handling.

Use it only carefully - e.g. in a exception catch case when calling .Close() failed. That's it's real purpose and proper use.

Marc

like image 76
marc_s Avatar answered Oct 30 '22 02:10

marc_s