/// <summary>
 /// Creates an Ananke wrapper and executes the application logic within that wrapper.
 /// </summary>
 /// <param name="settings">The settings to use for the Ananke wrapper.</param>
 /// <param name="action">The application logic to execute.</param>
 public static int Main(AnankeSettings settings, Func <AnankeContext, Task> action)
 {
     return(Main(settings, async context =>
     {
         await action(context).ConfigureAwait(false);
         return c_successExitCode;
     }));
 }
        /// <summary>
        /// Creates an Ananke wrapper with the specified settings.
        /// </summary>
        /// <param name="settings">The settings to use.</param>
        private AnankeRunner(AnankeSettings settings)
        {
            m_settings      = settings;
            m_log           = m_settings.LoggerFactory.CreateLogger("Ananke");
            m_exitRequested = new CancellationTokenSource();
            var loggingConsoleStdout =
                new StringLogTextWriter(new LoggingStringLog(m_settings.LoggerFactory, m_settings.StdoutParser));

            m_context       = new AnankeContext(m_settings.LoggerFactory, m_exitRequested.Token, loggingConsoleStdout);
            m_done          = new ManualResetEventSlim();
            m_exitCodeMutex = new object();
        }
#pragma warning restore

        /// <summary>
        /// Creates an Ananke wrapper and executes the application logic within that wrapper.
        /// </summary>
        /// <param name="settings">The settings to use for the Ananke wrapper.</param>
        /// <param name="action">The application logic to execute.</param>
        public static int Main(AnankeSettings settings, Action <AnankeContext> action) => Main(settings, context =>
        {
            action(context);
            return(c_successExitCode);
        });
#pragma warning disable 1998
        /// <summary>
        /// Creates an Ananke wrapper and executes the application logic within that wrapper.
        /// </summary>
        /// <param name="settings">The settings to use for the Ananke wrapper.</param>
        /// <param name="action">The application logic to execute.</param>
        public static int Main(AnankeSettings settings, Func <AnankeContext, int> action) =>
        Main(settings, async context => action(context));
        /// <summary>
        /// Creates an Ananke wrapper and executes the application logic within that wrapper.
        /// </summary>
        /// <param name="settings">The settings to use for the Ananke wrapper.</param>
        /// <param name="action">The application logic to execute.</param>
        public static int Main(AnankeSettings settings, Func <AnankeContext, Task <int> > action)
        {
            var runner = new AnankeRunner(settings);

            return(runner.Run(action));
        }