private bool QueryScheduledAction(ScheduledActionType action, ProgramStartupInfo psi, string msg)
        {
            if ((action == ScheduledActionType.None) ||
                (action == ScheduledActionType.LaunchProgram && psi == null))
                return false;

            string actionType = string.Empty;
            switch (action)
            {
                case ScheduledActionType.Shutdown:
                    actionType = Translator.Translate("TXT_SHUTDOWN_PC");
                    break;

                case ScheduledActionType.StandBy:
                    actionType = Translator.Translate("TXT_STANDBY_PC");
                    break;

                case ScheduledActionType.Hibernate:
                    actionType = Translator.Translate("TXT_HIBERNATE_PC");
                    break;

                case ScheduledActionType.LaunchProgram:
                    actionType = Translator.Translate("TXT_LAUNCH_PROGRAM");
                    break;
            }

            //RestoreWindowFromTray();

            string info = Translator.Translate("TXT_PROCEED_SCHEDULED_ACTION", actionType, msg);
            TimerWaitingDialog dlg = new TimerWaitingDialog(
                "TXT_SCHEDULED_ACTION_PROCEED", info, 60 * ProTONEConfig.SchedulerWaitTimerProceed);
            DialogResult res = dlg.ShowDialog();

            return (res == DialogResult.Yes);
        }
        private void PreProcessEvent(ScheduledActionType action, ProgramStartupInfo psi, string msg)
        {
            _action = action;
            _psi = psi;

            _canProceed.Reset();

            ThreadPool.QueueUserWorkItem(new WaitCallback(ProcessEvent));

            if (ProTONEConfig.SchedulerWaitTimerProceed > 0)
            {
                _action = ScheduledActionType.None;

                if (action != ScheduledActionType.None)
                {
                    Logger.LogInfo("Asking the user how to continue with action: " + action);

                    bool res = false;

                    MainThread.Send(delegate(object x)
                    {
                        res = QueryScheduledAction(action, psi, msg);

                    });

                    if (res)
                    {
                        Logger.LogInfo("The user has chosen to continue with the action");
                        _action = action;
                    }
                    else
                    {
                        Logger.LogInfo("The user has chosen to abort the action");
                    }
                }
            }

            _canProceed.Set();
        }