private void ProcessMessage5(ref MessageRpc rpc)
        {
            rpc.NextProcessor = _processMessage6;

            bool success = false;

            try
            {
                // If async call completes in sync, it tells us through the gate below
                rpc.PrepareInvokeContinueGate();

                SetActivityIdOnThread(ref rpc);

                rpc.Operation.InvokeBegin(ref rpc);
                success = true;
            }
            finally
            {
                try
                {
                    if (rpc.IsPaused)
                    {
                        // Check if the callback produced the async result and set it back on the RPC on this stack
                        // and proceed only if the gate was signaled by the callback and completed synchronously
                        if (rpc.UnlockInvokeContinueGate(out rpc.AsyncResult))
                        {
                            rpc.UnPause();
                        }
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    if (success && !rpc.IsPaused)
                    {
                        throw;
                    }

                    _error.HandleError(e);
                }
            }

            // Proceed if rpc is unpaused and invoke begin was successful.
            if (!rpc.IsPaused)
            {
                this.ProcessMessage6(ref rpc);
            }
        }
        void ProcessMessage5(ref MessageRpc rpc)
        {
            rpc.NextProcessor = this.processMessage6;

            try
            {
                bool success = false;
                try
                {
                    if (!rpc.Operation.IsSynchronous)
                    {
                        // If async call completes in [....], it tells us through the gate below
                        rpc.PrepareInvokeContinueGate();
                    }

                    if (this.transaction != null)
                    {
                        this.transaction.InitializeCallContext(ref rpc);
                    }

                    SetActivityIdOnThread(ref rpc);

                    rpc.Operation.InvokeBegin(ref rpc);
                    success = true;
                }
                finally
                {
                    try
                    {
                        try
                        {
                            if (this.transaction != null)
                            {
                                this.transaction.ClearCallContext(ref rpc);
                            }
                        }
                        finally
                        {
                            if (!rpc.Operation.IsSynchronous && rpc.IsPaused)
                            {
                                // Check if the callback produced the async result and set it back on the RPC on this stack 
                                // and proceed only if the gate was signaled by the callback and completed synchronously
                                if (rpc.UnlockInvokeContinueGate(out rpc.AsyncResult))
                                {
                                    rpc.UnPause();
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }

                        if (success && (rpc.Operation.IsSynchronous || !rpc.IsPaused))
                        {
                            throw;
                        }

                        this.error.HandleError(e);
                    }
                }
            }
            catch
            {
                // This catch clause forces ClearCallContext to run prior to stackwalks exiting this frame.
                throw;
            }

            // Proceed if rpc is unpaused and invoke begin was successful.
            if (!rpc.IsPaused)
            {
                this.ProcessMessage6(ref rpc);
            }
        }
        private void ProcessMessage5(ref MessageRpc rpc)
        {
            rpc.NextProcessor = _processMessage6;

            bool success = false;
            try
            {
                // If async call completes in sync, it tells us through the gate below
                rpc.PrepareInvokeContinueGate();

                SetActivityIdOnThread(ref rpc);

                rpc.Operation.InvokeBegin(ref rpc);
                success = true;
            }
            finally
            {
                try
                {
                    if (rpc.IsPaused)
                    {
                        // Check if the callback produced the async result and set it back on the RPC on this stack 
                        // and proceed only if the gate was signaled by the callback and completed synchronously
                        if (rpc.UnlockInvokeContinueGate(out rpc.AsyncResult))
                        {
                            rpc.UnPause();
                        }
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    if (success && !rpc.IsPaused)
                    {
                        throw;
                    }

                    _error.HandleError(e);
                }
            }

            // Proceed if rpc is unpaused and invoke begin was successful.
            if (!rpc.IsPaused)
            {
                this.ProcessMessage6(ref rpc);
            }
        }
 private void ProcessMessage5(ref MessageRpc rpc)
 {
     rpc.NextProcessor = this.processMessage6;
     try
     {
         bool flag = false;
         try
         {
             if (!rpc.Operation.IsSynchronous)
             {
                 rpc.PrepareInvokeContinueGate();
             }
             if (this.transaction != null)
             {
                 this.transaction.InitializeCallContext(ref rpc);
             }
             rpc.Operation.InvokeBegin(ref rpc);
             flag = true;
         }
         finally
         {
             try
             {
                 try
                 {
                     if (this.transaction != null)
                     {
                         this.transaction.ClearCallContext(ref rpc);
                     }
                 }
                 finally
                 {
                     if ((!rpc.Operation.IsSynchronous && rpc.IsPaused) && rpc.UnlockInvokeContinueGate(out rpc.AsyncResult))
                     {
                         rpc.UnPause();
                     }
                 }
             }
             catch (Exception exception)
             {
                 if (Fx.IsFatal(exception))
                 {
                     throw;
                 }
                 if (flag && (rpc.Operation.IsSynchronous || !rpc.IsPaused))
                 {
                     throw;
                 }
                 this.error.HandleError(exception);
             }
         }
     }
     catch
     {
         throw;
     }
     if (!rpc.IsPaused)
     {
         if (rpc.Operation.IsSynchronous)
         {
             this.ProcessMessage8(ref rpc);
         }
         else
         {
             this.ProcessMessage6(ref rpc);
         }
     }
 }