internal override async Task Execute(CommandObjects CommandObject) { await CommandObject.Message.RespondAsync("Logging out..."); Log.Info("Logging out..."); await ConsoleExitEvent.Main(0).ConfigureAwait(false); }
internal override async Task Execute(CommandObjects CommandObject) { await CommandObject.Message.RespondAsync("Restarting..."); Log.Info("Restarting..."); await ConsoleExitEvent.Main(-1); }
/// <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(); }