Inheritance: System.ComponentModel.AsyncCompletedEventArgs
Exemplo n.º 1
0
        static void OperationCompleted(object o)
        {
            var  state   = (SendAsyncState)o;
            var  client  = state.Client;
            var  handler = client.SendCompleted;
            bool dispose = true;

            try
            {
                if (handler != null)
                {
                    var args = new SendCompletedEventArgs(state.AsyncState.request, state.AsyncState.GetResponseOrNull(),
                                                          state.AsyncState.GetExceptionOrNull(), state.AsyncState.Cancelled, state.Operation.UserSuppliedState);
                    handler(client, args);
                    if (args.PreventAutomaticDispose)
                    {
                        dispose = false;
                    }
                }
            }
            finally
            {
                if (dispose)
                {
                    var x = state.AsyncState.GetResponseOrNull();
                    if (x != null)
                    {
                        x.Dispose();
                    }
                    var y = state.AsyncState.request;
                    if (y != null)
                    {
                        y.Dispose();
                    }
                }
            }
        }
Exemplo n.º 2
0
 static void OperationCompleted(object o)
 {
     var state = (SendAsyncState)o;
     var client = state.Client;
     var handler = client.SendCompleted;
     bool dispose = true;
     try
     {
         if (handler != null)
         {
             var args = new SendCompletedEventArgs(state.AsyncState.request, state.AsyncState.GetResponseOrNull(),
                 state.AsyncState.GetExceptionOrNull(), state.AsyncState.Cancelled, state.Operation.UserSuppliedState);
             handler(client, args);
             if (args.PreventAutomaticDispose)
             {
                 dispose = false;
             }
         }
     }
     finally
     {
         if (dispose)
         {
             var x = state.AsyncState.GetResponseOrNull();
             if (x != null)
             {
                 x.Dispose();
             }
             var y = state.AsyncState.request;
             if (y != null)
             {
                 y.Dispose();
             }
         }
     }
 }