コード例 #1
0
        private Task <byte[]> ActorMethodDispatch(
            Remoting.V1.Builder.ActorMethodDispatcherBase methodDispatcher,
            ActorBase actor,
            int interfaceId,
            int methodId,
            object requestBody,
            CancellationToken innerCancellationToken)
        {
            var actorInterfaceMethodKey = DiagnosticsEventManager.GetInterfaceMethodKey((uint)interfaceId,
                                                                                        (uint)methodId);

            this.DiagnosticsEventManager.ActorMethodStart(actorInterfaceMethodKey, actor, RemotingListener.V1Listener);

            Task <object> dispatchTask;

            try
            {
                dispatchTask = methodDispatcher.DispatchAsync(actor, methodId, requestBody, innerCancellationToken);
            }
            catch (Exception e)
            {
                this.DiagnosticsEventManager.ActorMethodFinish(actorInterfaceMethodKey, actor, e,
                                                               RemotingListener.V1Listener);
                throw;
            }

            return(dispatchTask.ContinueWith(
                       t =>
            {
                object responseMsgBody = null;
                try
                {
                    responseMsgBody = t.GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    this.DiagnosticsEventManager.ActorMethodFinish(actorInterfaceMethodKey, actor, e,
                                                                   RemotingListener.V1Listener);
                    throw;
                }
                this.DiagnosticsEventManager.ActorMethodFinish(actorInterfaceMethodKey, actor, null,
                                                               RemotingListener.V1Listener);

                var serializationStartTime = DateTime.UtcNow;
                var serializedResponse = methodDispatcher.SerializeResponseMessageBody(responseMsgBody);
                this.DiagnosticsEventManager.ActorResponseSerializationFinish(serializationStartTime);

                return serializedResponse;
            },
                       TaskContinuationOptions.ExecuteSynchronously));
        }
コード例 #2
0
        private Task <IServiceRemotingResponseMessageBody> ActorMethodDispatch(
            Remoting.V2.Builder.ActorMethodDispatcherBase methodDispatcher, ActorBase actor, int interfaceId,
            int methodId,
            IServiceRemotingRequestMessageBody requestBody,
            IServiceRemotingMessageBodyFactory remotingMessageBodyFactory, CancellationToken innerCancellationToken)
        {
            var actorInterfaceMethodKey =
                DiagnosticsEventManager.GetInterfaceMethodKey((uint)interfaceId, (uint)methodId);

            this.DiagnosticsEventManager.ActorMethodStart(actorInterfaceMethodKey, actor, RemotingListener.V2Listener);

            Task <IServiceRemotingResponseMessageBody> dispatchTask;

            try
            {
                dispatchTask = methodDispatcher.DispatchAsync(actor, methodId, requestBody, remotingMessageBodyFactory,
                                                              innerCancellationToken);
            }
            catch (Exception e)
            {
                this.DiagnosticsEventManager.ActorMethodFinish(actorInterfaceMethodKey, actor, e,
                                                               RemotingListener.V2Listener);
                throw;
            }

            return(dispatchTask.ContinueWith(
                       t =>
            {
                IServiceRemotingResponseMessageBody responseMsgBody = null;
                try
                {
                    responseMsgBody = t.GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    this.DiagnosticsEventManager.ActorMethodFinish(actorInterfaceMethodKey, actor, e,
                                                                   RemotingListener.V2Listener);
                    throw;
                }
                this.DiagnosticsEventManager.ActorMethodFinish(actorInterfaceMethodKey, actor, null,
                                                               RemotingListener.V2Listener);


                return responseMsgBody;
            },
                       TaskContinuationOptions.ExecuteSynchronously));
        }