public void TryStartExecuteNew(string rawInput) { var parameters = requestsParametersParser.ParseParametersOrNull(rawInput); if (parameters == null) { return; } var traceId = traceIdProvider.GetNext(); var requestUserMessagePrinter = printersCache.GetOrAdd($"{scope}_{traceId}"); requestUserMessagePrinter.RequestExecutionStarted(); executingTasksByIds[traceId] = Task.Run(() => { try { Execute(parameters, requestUserMessagePrinter); } catch (Exception e) { requestUserMessagePrinter.UnderlyingPrinter.Print(e.ToString()); throw; } finally { executingTasksByIds.TryRemove(traceId, out _); requestUserMessagePrinter.RequestExecutionEnded(); } }); }
public Service(IExecutingRequestsCollection[] executingRequestsCollections, IUserRawInputProvider userRawInputProvider, UserMessagePrintersCache printersCache, IUserConsentProvider userConsentProvider) { this.executingRequestsCollections = executingRequestsCollections; this.userRawInputProvider = userRawInputProvider; this.userConsentProvider = userConsentProvider; serviceUserMessagePrinter = printersCache.GetOrAdd("Service"); }