public Task <ICommandResult> RegisterProcessingCommand(string commandId, ICommand command, CommandReturnMode commandReturnMode, int timeoutMs) { var taskCompletionSource = new CommandTaskCompletionSource(commandReturnMode, timeoutMs, commandId, _commandTaskDict.Remove); if (!_commandTaskDict.TryAdd(commandId, taskCompletionSource)) { taskCompletionSource.Dispose(); throw new ApplicationException( string.Format("Duplicate processing command registration, type:{0}, id:{1}", command.GetType().Name, commandId)); } return(taskCompletionSource.Task); }
/// <summary> /// Event will be fired on user input. /// </summary> /// <param name="sender">The object which fired the event</param> /// <param name="e">The user input</param> private void BlazorConsoleComponent_CommandInputEvent(object sender, string e) { CommandTaskCompletionSource?.SetResult(e); }