Beispiel #1
0
        /// <summary>
        /// Método de finalização da requisição assincrona.
        /// </summary>
        /// <param name="result"></param>
        private void EndRequest(IAsyncResult result)
        {
            var asyncState = result.AsyncState as AsyncOperationBase;

            if (asyncState != null)
            {
                try
                {
                    asyncState.EndOperation(result);
                    asyncState.Complete();
                }
                catch (MessageSecurityException exception)
                {
                    if (!ServiceProxy <T> .IsAuthenticationFailure(exception.InnerException as FaultException))
                    {
                        asyncState.InnerException = exception;
                        asyncState.Complete();
                    }
                }
                catch (CryptographicException)
                {
                }
                catch (Exception exception2)
                {
                    asyncState.InnerException = exception2;
                    asyncState.Complete();
                }
                if (!asyncState.IsCompleted)
                {
                    if (!asyncState.UsingTransportSecurity)
                    {
                        asyncState.Complete();
                    }
                    else
                    {
                        if (asyncState.UsingCachedCertificate)
                        {
                            asyncState.UsingCachedCertificate = false;
                        }
                        asyncState.CertificateIndex++;
                        this.BeginOperation(asyncState);
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// tenta executar.
 /// </summary>
 /// <typeparam name="TResult"></typeparam>
 /// <param name="action"></param>
 /// <param name="channel"></param>
 /// <param name="result"></param>
 /// <returns></returns>
 private bool TryDo <TResult>(Func <T, TResult> action, T channel, out TResult result)
 {
     try
     {
         result = action.Invoke(channel);
         return(true);
     }
     catch (MessageSecurityException exception)
     {
         if (!ServiceProxy <T> .IsAuthenticationFailure(exception.InnerException as FaultException))
         {
             throw;
         }
     }
     catch (CryptographicException)
     {
     }
     result = default(TResult);
     return(false);
 }