Exemplo n.º 1
0
 public static void Using <TChannel>(this System.ServiceModel.ClientBase <TChannel> client, Action <System.ServiceModel.ClientBase <TChannel> > work) where TChannel : class
 {
     work(client);
     try
     {
         client.Close();
     }
     catch (Exception e)
     {
         client.Abort();
     }
 }
Exemplo n.º 2
0
        public static TReturn Using <TChannel, TReturn>(this System.ServiceModel.ClientBase <TChannel> client, Func <System.ServiceModel.ClientBase <TChannel>, TReturn> work) where TChannel : class
        {
            var result = default(TReturn);

            result = work(client);
            try
            {
                client.Close();
            }
            catch (Exception e)
            {
                client.Abort();
            }
            return(result);
        }