private void Invoker(ShutdownType type) { try { switch (type) { case ShutdownType.Shutdown: ShutdownInvoker.InvokeShutdown(); break; case ShutdownType.Hibernate: ShutdownInvoker.SetSuspendState(true, true, true); break; case ShutdownType.Sleep: ShutdownInvoker.SetSuspendState(false, true, true); break; case ShutdownType.LogOff: ShutdownInvoker.InvokeLogOffSvc(); break; case ShutdownType.Restart: ShutdownInvoker.InvokeRestart(); break; } } catch (Exception ex) { LogError(ex.Message); } }
private void ProcessCommand(string shutdownType) { try { switch (shutdownType) { case "Shutdown": ShutdownInvoker.InvokeShutdown(); break; case "Hibernate": ShutdownInvoker.SetSuspendState(true, true, true); break; case "Restart": ShutdownInvoker.InvokeRestart(); break; case "Sleep": ShutdownInvoker.SetSuspendState(false, true, true); break; case "Log Off": ShutdownInvoker.ExitWindowsEx(0, 0); break; case "Lock": ShutdownInvoker.LockWorkStation(); break; } } catch (Exception ex) { OnCancel(); OnErrorOccured(ex.Message); } }