public CLIRequest(ICLIClient client, Master ctrl, string cmdLine) { this.ctrl = ctrl; Client = client; Commands = new Queue <ICommand>(); cmdRepo = new CommandRepository(ctrl); DirigentCommandRegistrator.Register(cmdRepo); // parse commands and fill cmd queue string?restAfterUid; SplitToUuidAndRest(cmdLine, out Uid, out restAfterUid); if (string.IsNullOrEmpty(restAfterUid)) { Finished = true; _mutex = new SemaphoreSlim(1); return; } try { var cmdList = cmdRepo.ParseCmdLine(client.Name, restAfterUid, WriteResponseLine); Commands = new Queue <ICommand>(cmdList); _mutex = new SemaphoreSlim(0); } catch (Exception e) { // take just first line of exception description string excMsg = e.ToString(); var crPos = excMsg.IndexOf('\r'); var lfPos = excMsg.IndexOf('\n'); if (crPos >= 0 || lfPos >= 0) { excMsg = excMsg.Substring(0, Math.Min(crPos, lfPos)); } WriteResponseLine("ERROR: " + Tools.JustFirstLine(e.Message)); Finished = true; _mutex = new SemaphoreSlim(1); _except = e; } }