public void Restart(bool force = false) { ServiceRegistration.Get <ILogger>().Info("SystemStateService: Restarting"); SystemMessaging.SendSystemStateChangeMessage(SystemState.ShuttingDown); WindowsAPI.EXIT_WINDOWS flags = WindowsAPI.EXIT_WINDOWS.EWX_REBOOT; if (force) { flags |= WindowsAPI.EXIT_WINDOWS.EWX_FORCE; } WindowsAPI.ExitWindowsEx(flags); }
public void Shutdown(bool force = false) { ServiceRegistration.Get <ILogger>().Info("SystemStateService: Shutting down"); SystemMessaging.SendSystemStateChangeMessage(SystemState.ShuttingDown); WindowsAPI.EXIT_WINDOWS flags = WindowsAPI.EXIT_WINDOWS.EWX_POWEROFF; if (force) { flags |= WindowsAPI.EXIT_WINDOWS.EWX_FORCE; } // todo: chefkoch, 2013-01-31: add flag for HybridShutdown if OS is Windows 8 WindowsAPI.ExitWindowsEx(flags); }