Пример #1
0
            static void OnComplete(object parameter)
            {
                ReceiveContextAsyncResult result = parameter as ReceiveContextAsyncResult;
                Exception   completionException  = null;
                Transaction savedTransaction     = null;

                try
                {
                    // set the current transaction object for this worker thread as this operation could
                    // have been scheduled by another worker thread. We do not want to complete in
                    // worker threads ambient transaction. associatedTransaction can be null.
                    savedTransaction    = Transaction.Current;
                    Transaction.Current = result.associatedTransaction;
                    result.receiver.OnComplete(result.timeoutHelper.RemainingTime());
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    completionException = e;
                }
                finally
                {
                    Transaction.Current = savedTransaction;
                }
                result.Complete(false, completionException);
            }
Пример #2
0
            static void OnAbandon(object parameter)
            {
                ReceiveContextAsyncResult result = parameter as ReceiveContextAsyncResult;
                Exception completionException    = null;

                try
                {
                    result.receiver.OnAbandon(result.timeoutHelper.RemainingTime());
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    completionException = e;
                }
                result.Complete(false, completionException);
            }