/// <summary> /// Signals that the command is done executing regardless of the outcome. /// </summary> /// <param name="completionEventType">The event that was raised signaling that the execution is done.</param> internal void SignalExecutionDone(CommandExecutionEventType completionEventType) { if (Interlocked.CompareExchange(ref this.isDone, Constants.TrueInt, Constants.FalseInt) != Constants.FalseInt) { throw new InvalidOperationException("The command has already been marked as done."); } this.ExecutionLatency = (int)(DateTime.UtcNow - this.StartDateTime).TotalMilliseconds; this.AddEvent(completionEventType); }
/// <summary> /// Adds an event. /// </summary> /// <param name="eventType">An event.</param> internal void AddEvent(CommandExecutionEventType eventType) { this.events.Add(eventType); }
private void ExcecutionDone <TResponse>(BaseCommand <TResponse> command, CommandResult <TResponse> commandResult, CommandExecutionEventType eventType) { commandResult.SignalExecutionDone(eventType); this.eventPublisher.Publish(new CommandExecutedEvent(command.CommandKey, commandResult)); }