private static void OnEnterComplete(object state, Exception asyncException)
            {
                FramingDuplexSessionChannel.SendAsyncResult result = (FramingDuplexSessionChannel.SendAsyncResult)state;
                bool      flag      = false;
                Exception exception = asyncException;

                if (exception != null)
                {
                    flag = true;
                }
                else
                {
                    try
                    {
                        flag = result.WriteCore();
                    }
                    catch (Exception exception2)
                    {
                        if (Fx.IsFatal(exception2))
                        {
                            throw;
                        }
                        flag      = true;
                        exception = exception2;
                    }
                }
                if (flag)
                {
                    result.Cleanup(exception == null, asyncException == null);
                    result.Complete(false, exception);
                }
            }
 private static void OnWriteComplete(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         FramingDuplexSessionChannel.SendAsyncResult asyncState = (FramingDuplexSessionChannel.SendAsyncResult)result.AsyncState;
         Exception exception = null;
         try
         {
             asyncState.channel.Connection.EndWrite(result);
         }
         catch (Exception exception2)
         {
             if (Fx.IsFatal(exception2))
             {
                 throw;
             }
             exception = exception2;
         }
         asyncState.Cleanup(exception == null, true);
         asyncState.Complete(false, exception);
     }
 }