Example #1
0
        /// <summary>
        /// Wrapper for the Shutdown function that logs out information about the type of shutdown that the application is
        /// performing.
        /// </summary>
        /// <param name="code">The result code being returned by the application</param>
        private void DoShutdown(ResultCode code = ResultCode.Success)
        {
            // Marshal to the dispatcher thread if necessary
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(() => DoShutdown(code));
                return;
            }

            // Log out the reason for shutting down
            var targetLevel = code.IsError() ? Level.Warn : Level.Info;

            if (Logger.Logger.IsEnabledFor(targetLevel))
            {
                Logger.Logger.Log(GetType(), targetLevel, $"Application shutting down with code {code.ToInt()} ({code})", null);
            }

            // Exit the application with the specified code
            Shutdown(code.ToInt());
        }