Exemple #1
0
 public void UseAsync(UseServiceDelegate <T> action, string endPoint, AsyncCallback callBack, object obj)
 {
     try
     {
         _proxy = GetChannelFactory(endPoint).CreateChannel() as IClientChannel;
         if (_proxy != null)
         {
             _proxy.Open();
             _callBack = callBack;
             _action   = action;
             IAsyncResult result = _action.BeginInvoke((T)_proxy, AsyncResult, obj);
         }
     }
     catch (CommunicationException communicationException)
     {
         if (_proxy != null)
         {
             _proxy.Abort();
         }
         throw communicationException;
     }
     catch (TimeoutException timeoutException)
     {
         if (_proxy != null)
         {
             _proxy.Abort();
         }
         throw timeoutException;
     }
     catch (Exception ex)
     {
         if (_proxy != null)
         {
             _proxy.Abort();
         }
         throw ex;
     }
 }