Пример #1
0
        internal async Task <MessageRpc> ProcessAsync(bool isOperationContextSet)
        {
            MessageRpc result = this;
            //using (ServiceModelActivity.BoundOperation(this.Activity))
            //{
            // bool completed = true;

            OperationContext originalContext;

            OperationContext.Holder contextHolder;
            if (!isOperationContextSet)
            {
                contextHolder   = OperationContext.CurrentHolder;
                originalContext = contextHolder.Context;
            }
            else
            {
                contextHolder   = null;
                originalContext = null;
            }
            IncrementBusyCount();

            try
            {
                if (!isOperationContextSet)
                {
                    contextHolder.Context = OperationContext;
                }

                await AsyncProcessor(this);

                OperationContext.SetClientReply(null, false);
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                if (!ProcessError(e) && FaultInfo.Fault == null)
                {
                    Abort();
                }
            }
            finally
            {
                try
                {
                    DecrementBusyCount();

                    if (!isOperationContextSet)
                    {
                        contextHolder.Context = originalContext;
                    }

                    OperationContext.ClearClientReplyNoThrow();
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperFatal(e.Message, e);
                }
            }

            return(this);
            //}
        }