示例#1
0
        internal override async Task Execute(CommandObjects CommandObject)
        {
            await CommandObject.Message.RespondAsync("Logging out...");

            Log.Info("Logging out...");

            await ConsoleExitEvent.Main(0).ConfigureAwait(false);
        }
示例#2
0
        internal override async Task Execute(CommandObjects CommandObject)
        {
            await CommandObject.Message.RespondAsync("Restarting...");

            Log.Info("Restarting...");

            await ConsoleExitEvent.Main(-1);
        }
示例#3
0
        /// <summary>
        /// Starts new thread and waits while any key will be pressed in console.
        /// </summary>
        /// <param name="exitEvent">ManualResetEvent, invokes when any key will be pressed.</param>
        /// <returns></returns>
        public static void WaitConsoleReadKey(ConsoleExitEvent exitEvent)
        {
            ConsoleKeyInfo exitKey       = new ConsoleKeyInfo();
            Thread         readKeyThread = new Thread(() =>
            {
                exitKey           = Console.ReadKey();
                exitEvent.KeyInfo = (ConsoleKeyInfo)exitKey;
                exitEvent.Set();
            });

            readKeyThread.IsBackground = true;
            readKeyThread.Start();
        }