Exemplo n.º 1
0
        private bool Handle(InvokeMessage <TRequest, TReply> message)
        {
            if (!message.TryBeginHandle())
            {
                return(false);
            }

            try
            {
                _handler.Invoke(message.Request)
                .ContinueWith(OnCompleted, message, TaskContinuationOptions.ExecuteSynchronously);
            }
            catch (OperationCanceledException)
            {
                message.SetCanceled();
            }
            catch (Exception ex)
            {
                message.SetException(ex);
            }

            return(true);
        }
Exemplo n.º 2
0
        private bool Handle(InvokeMessage <TRequest, TReply> message)
        {
            if (!message.TryBeginHandle())
            {
                return(false);
            }

            try
            {
                var result = _handler.Invoke(message.Request);
                message.SetResult(result);
            }
            catch (OperationCanceledException)
            {
                message.SetCanceled();
            }
            catch (Exception ex)
            {
                message.SetException(ex);
            }

            return(true);
        }