Пример #1
0
        /// <summary>
        /// Cause the Main() to return with a given status code.
        /// </summary>
        /// <param name="exitCode">Reason for termination.</param>
        /// <returns>Exits before returning the exit code.</returns>
        public static int ExitProgramWithCode(ExitCode exitCode)
        {
            // Flush the logs by disposing the factory
            _loggerFactory?.Dispose();
            if (exitCode != ExitCode.Success)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"----------------------------------");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"Exiting program with code {exitCode}");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"----------------------------------");
            }

            DatabaseEventListenerService.CloseSession(exitCode);

            Env.ExitEnvironment((int)exitCode);
            return((int)exitCode);
        }