Exemplo n.º 1
0
        public void OnNext(RuntimeStop runtimeStop)
        {
            Logger.Log(Level.Verbose, "Runtime stop");

            lock (_heartBeatManager)
            {
                if (_state == State.RUNNING)
                {
                    const string msg = "RuntimeStopHandler invoked in state RUNNING.";
                    if (runtimeStop.Exception != null)
                    {
                        OnException(new SystemException(msg, runtimeStop.Exception));
                    }
                    else
                    {
                        OnException(new SystemException(msg));
                    }
                }
                else
                {
                    var successfulExit = true;
                    try
                    {
                        _contextManager.Dispose();
                        _evaluatorControlChannel.Dispose();
                    }
                    catch (Exception e)
                    {
                        successfulExit = false;
                        Utilities.Diagnostics.Exceptions.CaughtAndThrow(
                            new InvalidOperationException("Cannot stop evaluator properly", e),
                            Level.Error,
                            "Exception during shut down.",
                            Logger);
                    }
                    finally
                    {
                        _evaluatorExitLogger.LogExit(successfulExit);
                    }
                }
            }
        }