Пример #1
0
 public static void Hibernate()
 {
     Task.Factory.StartNew(() =>
     {
         if (PowerStatusBox.PowerAction("Hibernate", 10))
         {
             SetSuspendState(true, true, true);
         }
     });
 }
Пример #2
0
 public static void Shutdown()
 {
     Task.Factory.StartNew(() =>
     {
         if (PowerStatusBox.PowerAction("Shut Down", 10))
         {
             ProcessStartInfo si = new ProcessStartInfo("shutdown", "/s /t 0");
             si.CreateNoWindow   = true;
             si.WindowStyle      = ProcessWindowStyle.Hidden;
             Process.Start(si);
         }
     });
 }
        public static bool PowerAction(string action, int seconds)
        {
            bool ret = false;

            App.Current.Dispatcher.Invoke((Action)delegate
            {
                PowerStatusBox frm = new PowerStatusBox();

                frm.Action = action;
                frm.Seconds = seconds;
                frm.Status();
                ret = (bool)frm.ShowDialog();
            });

            return ret;
        }
        public static bool PowerAction(string action, int seconds)
        {
            bool ret = false;

            App.Current.Dispatcher.Invoke((Action) delegate
            {
                PowerStatusBox frm = new PowerStatusBox();

                frm.Action  = action;
                frm.Seconds = seconds;
                frm.Status();
                ret = (bool)frm.ShowDialog();
            });

            return(ret);
        }