public Task OnReportFinishTaskSuccess(string taskId, long instanceId) { PendingCommandContext startContext = this.pendingStartCommands.Remove(taskId); if (startContext != null) { startContext.Cancel(); } PendingCommandContext finishContext = this.pendingFinishCommands.Get(taskId); if (finishContext != null) { if (finishContext.ShouldInjectFault) { return(Task.Factory.StartNew(() => { throw new InvalidOperationException("OnReportFinishTaskSuccess: Injected Fault"); })); } if (finishContext.InstanceId == instanceId) { finishContext.Complete(); this.pendingFinishCommands.Remove(taskId); } else { // Not the instance we were expecting, request again with // the current instance this.ProcessFinishCommand(finishContext); } } return(Utility.CreateCompletedTask <object>(null)); }
public Task OnReportStartTaskSuccess(string taskId, long instanceId) { PendingCommandContext commandContext = this.pendingStartCommands.Get(taskId); if (commandContext != null) { if (commandContext.ShouldInjectFault) { return(Task.Factory.StartNew(() => { throw new InvalidOperationException("OnReportStartTaskSuccess: Injected Fault"); })); } if (commandContext.InstanceId == instanceId) { commandContext.Complete(); // Leave start context in map for correlation with finish context } else { // Not the instance we were expecting, request again with // the current instance this.ProcessStartCommand(commandContext); } } return(Utility.CreateCompletedTask <object>(null)); }