Example #1
0
        static void CloseInstanceContextCallback(IAsyncResult result)
        {
            if (result.CompletedSynchronously)
            {
                return;
            }
            InstanceContext instanceContext = (InstanceContext)result.AsyncState;

            try
            {
                instanceContext.EndClose(result);
            }
            catch (ObjectDisposedException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
            }
            catch (InvalidOperationException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
            }
            catch (CommunicationException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
            }
            catch (TimeoutException e)
            {
                if (TD.CloseTimeoutIsEnabled())
                {
                    TD.CloseTimeout(e.Message);
                }
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
            }
        }
Example #2
0
        static void CloseCallback(IAsyncResult asyncResult)
        {
            InstanceContext serviceInstance = asyncResult.AsyncState as InstanceContext;

            try
            {
                serviceInstance.EndClose(asyncResult);
            }
            catch (CommunicationException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
            }
            catch (TimeoutException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
            }
        }
Example #3
0
        void CloseInitiate(TimeSpan timeout)
        {
            TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);

            InstanceContext[] instances = this.ToArray();
            for (int index = 0; index < instances.Length; index++)
            {
                InstanceContext instance = instances[index];
                try
                {
                    if (instance.State == CommunicationState.Opened)
                    {
                        IAsyncResult result = instance.BeginClose(timeoutHelper.RemainingTime(), Fx.ThunkCallback(new AsyncCallback(CloseInstanceContextCallback)), instance);
                        if (!result.CompletedSynchronously)
                        {
                            continue;
                        }
                        instance.EndClose(result);
                    }
                    else
                    {
                        instance.Abort();
                    }
                }
                catch (ObjectDisposedException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                }
                catch (InvalidOperationException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                }
                catch (CommunicationException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                }
                catch (TimeoutException e)
                {
                    if (TD.CloseTimeoutIsEnabled())
                    {
                        TD.CloseTimeout(e.Message);
                    }
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                }
            }
        }
 private static void CloseInstanceContextCallback(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         InstanceContext asyncState = (InstanceContext)result.AsyncState;
         try
         {
             asyncState.EndClose(result);
         }
         catch (ObjectDisposedException exception)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information);
             }
         }
         catch (InvalidOperationException exception2)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information);
             }
         }
         catch (CommunicationException exception3)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Information);
             }
         }
         catch (TimeoutException exception4)
         {
             if (DiagnosticUtility.ShouldTraceInformation)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception4, TraceEventType.Information);
             }
         }
     }
 }