public AcceptAsyncResult(SocketConnectionListener listener, AsyncCallback callback, object state) : base(callback, state)
 {
     this.listener                        = listener;
     this.socketAsyncEventArgs            = listener.TakeSocketAsyncEventArgs();
     this.socketAsyncEventArgs.UserToken  = this;
     this.socketAsyncEventArgs.Completed += acceptAsyncCompleted;
     base.OnCompleting                    = onCompleting;
     if (!Thread.CurrentThread.IsThreadPoolThread)
     {
         if (startAccept == null)
         {
             startAccept = new Action <object>(SocketConnectionListener.AcceptAsyncResult.StartAccept);
         }
         ActionItem.Schedule(startAccept, this);
     }
     else
     {
         bool flag;
         bool flag2 = false;
         try
         {
             flag  = this.StartAccept();
             flag2 = true;
         }
         finally
         {
             if (!flag2)
             {
                 this.ReturnSocketAsyncEventArgs();
             }
         }
         if (flag)
         {
             base.Complete(true);
         }
     }
 }
            public AcceptAsyncResult(SocketConnectionListener listener, AsyncCallback callback, object state)
                : base(callback, state)
            {

                if (TD.SocketAcceptEnqueuedIsEnabled())
                {
                    TD.SocketAcceptEnqueued(this.EventTraceActivity);
                }

                Fx.Assert(listener != null, "listener should not be null");
                this.listener = listener;
                this.socketAsyncEventArgs = listener.TakeSocketAsyncEventArgs();
                this.socketAsyncEventArgs.UserToken = this;
                this.socketAsyncEventArgs.Completed += acceptAsyncCompleted;
                this.OnCompleting = onCompleting;

                // If we're going to start up the thread pool eventually anyway, avoid using RegisterWaitForSingleObject
                if (!Thread.CurrentThread.IsThreadPoolThread)
                {
                    if (startAccept == null)
                    {
                        startAccept = new Action<object>(StartAccept);
                    }

                    ActionItem.Schedule(startAccept, this);
                }
                else
                {
                    bool completeSelf;
                    bool success = false;
                    try
                    {
                        completeSelf = StartAccept();
                        success = true;
                    }
                    finally
                    {
                        if (!success)
                        {
                            // Return the args when an exception is thrown
                            ReturnSocketAsyncEventArgs();
                        }
                    }

                    if (completeSelf)
                    {
                        base.Complete(true);
                    }
                }
            }
 public AcceptAsyncResult(SocketConnectionListener listener, AsyncCallback callback, object state) : base(callback, state)
 {
     this.listener = listener;
     this.socketAsyncEventArgs = listener.TakeSocketAsyncEventArgs();
     this.socketAsyncEventArgs.UserToken = this;
     this.socketAsyncEventArgs.Completed += acceptAsyncCompleted;
     base.OnCompleting = onCompleting;
     if (!Thread.CurrentThread.IsThreadPoolThread)
     {
         if (startAccept == null)
         {
             startAccept = new Action<object>(SocketConnectionListener.AcceptAsyncResult.StartAccept);
         }
         ActionItem.Schedule(startAccept, this);
     }
     else
     {
         bool flag;
         bool flag2 = false;
         try
         {
             flag = this.StartAccept();
             flag2 = true;
         }
         finally
         {
             if (!flag2)
             {
                 this.ReturnSocketAsyncEventArgs();
             }
         }
         if (flag)
         {
             base.Complete(true);
         }
     }
 }