public void TryStartApplication_WhenApplicationStartFails_StopsPipeServer()
        {
            var starter = BuildMaybePipedApplicationStarter(2);

            var         counter   = 0;
            Func <bool> startFunc = () =>
            {
                if (++counter <= 1)
                {
                    throw new Exception();
                }
                return(true);
            };

            Assert.Throws <Exception>(() => starter.SendMessageOrStartApplication(() => "", startFunc, true));

            Received.InOrder(() =>
            {
                _settingsManager.LoadAllSettings();
                _pipeServerManager.IsServerRunning();
                _pipeServerManager.StartServer();
                // Expect Shutdown directly, as this will stop the pipe server after an error
                _pipeServerManager.Shutdown();
            });
        }
        private void Shutdown()
        {
            _logger.Debug("Waiting for all threads to finish");
            _threadManager.WaitForThreads();

            _pipeServerManager.PrepareShutdown();

            _threadManager.Shutdown();

            _settingsManager.SaveCurrentSettings();

            _pipeServerManager.Shutdown();
        }
Ejemplo n.º 3
0
        private async Task Shutdown()
        {
            _logger.Debug("Waiting for all threads to finish");
            await _threadManager.WaitForThreads();

            _pipeServerManager.PrepareShutdown();

            _threadManager.Shutdown();

            _settingsManager.SaveCurrentSettings();
            _jobHistoryActiveRecord.Save();

            _pipeServerManager.Shutdown();
        }
Ejemplo n.º 4
0
        public void ReleaseCom()
        {
            if (_isComActive)
            {
                if (!_threadPool.Join(TimeSpan.FromSeconds(4)))
                {
                    throw new COMException("One of the thread jobs didn't finish within the time out.");
                }

                Logger.Trace("COM: Cleaning up COM resources.");
                if (IsServerInstanceRunning)
                {
                    _pipeServerManager.Shutdown();
                }

                _isComActive = false;

                Logger.Trace("COM: Emptying queue.");
                Clear();
            }
            else
            {
                throw new COMException("No COM Instance was found.");
            }
        }