/// <summary> /// Starts the Core by starting the Pipe Service and Task /// Service /// </summary> private void StartCore() { // Is Core not already started? if ((bool)_memoryCache.Get(SERVICE_MEMORY) == false) { // Print appropriate message AddLineToBuffer((List <string>)_memoryCache.Get(CliScreen), StartReceipt); _loggerService.LogMessage(SERVICE_NAME, "Starting Pipe Server Core Service...", LogLevel.Debug ); var startPipe = new int(); // Spin up new Thread for Pipe Server Service Start new Thread(() => { try { _pipeService.Start(); } catch (PipeServiceException pse) { // Print appropriate message AddLineToBuffer((List <string>) _memoryCache.Get(CliScreen), StartFail); _loggerService.LogMessage(SERVICE_NAME, pse.Message, LogLevel.Error ); startPipe = -1; return; } startPipe = 0; }).Start(); if (startPipe < 0) { return; } _loggerService.LogMessage(SERVICE_NAME, "Starting Task Core Service...", LogLevel.Debug); var startTask = new int(); // Spin up new Thread for Task Service Start new Thread(() => { try { _taskService.Start(); } catch (TaskServiceException tse) { // Print appropriate message AddLineToBuffer((List <string>) _memoryCache.Get(CliScreen), StartFail); _loggerService.LogMessage(SERVICE_NAME, tse.Message, LogLevel.Error ); startTask = -1; return; } startTask = 0; }).Start(); if (startTask < 0) { return; } // Set Core Started boolean _memoryCache.Set(SERVICE_MEMORY, true); // Print appropriate message AddLineToBuffer((List <string>)_memoryCache.Get(CliScreen), StartConfirm); } // Core already started, print appropriate message else { // Print appropriate message AddLineToBuffer((List <string>)_memoryCache.Get(CliScreen), StartAlready); } }
/// <summary> /// Starts up all the services that are enabled in the configuration /// </summary> /// <param name="serialNumber">Requires an <see cref="int" /></param> public void Run(uint serialNumber, bool shouldStart, bool shouldStress) { SerialNumber = serialNumber; foreach (var component in _config.Components) { switch (component.Name) { case "InteractiveConsoleService": if (component.Properties.Enabled) { new Thread(() => { _interactiveConsoleService.Start(); //Thread.Sleep(1000); }).Start(); } break; case "PipeService": if (component.Properties.Enabled) { new Thread(() => { _pipeService.Start(); //Thread.Sleep(1000); }).Start(); } break; case "TaskService": if (component.Properties.Enabled) { new Thread(() => { _taskService.Start(); //Thread.Sleep(1000); }).Start(); } break; case "TCPService": if (component.Properties.Enabled) { new Thread(() => { _tcpService.Start(); //Thread.Sleep(1000); }).Start(); } break; case "ErrorProcessingService": if (component.Properties.Enabled) { new Thread(() => { _errorProcessingService.Start(); //Thread.Sleep(1000); }).Start(); } break; case "CMDRunnerService": if (component.Properties.Enabled) { new Thread(() => { _commandRunnerService.Start(); //Thread.Sleep(1000); }).Start(); } break; case "InterrogatorService": if (component.Properties.Enabled) { new Thread(() => { _interrogatorService.Start(); //Thread.Sleep(1000); }).Start(); } break; default: break; } } if (!shouldStart && !shouldStress) { return; } if (!shouldStart) { return; } CreateStartTask(shouldStress); }