Example #1
0
        protected static void ExitWindowsDefaultThread(object _data)
        {
            ExitWindowsDefaultEnv env = (ExitWindowsDefaultEnv)_data;
            RestartOptions        how = env.how;
            bool force = env.force;

            Log.Debug("WindowsController: Performing ExitWindows {0}, force: {1}", how, force);
            bool res;

            switch (how)
            {
            case RestartOptions.Suspend:
                res = Application.SetSuspendState(PowerState.Suspend, force, false);
                break;

            case RestartOptions.Hibernate:
                res = Application.SetSuspendState(PowerState.Hibernate, force, false);
                break;

            default:
                res = ExitWindowsInt((int)how, force);
                break;
            }
            Log.Debug("WindowsController: ExitWindows performed, result: {0}", res);
            if (env.after != null)
            {
                env.after(how, force, res);
            }
        }