static ProcessPriorityWrapper() { AllValues = new ProcessPriorityWrapper[Enum.GetValues(typeof(NativeMethods.PriorityClass)).Length - 2]; /* * ; PROCESS_MODE_BACKGROUND_END = new ProcessPriorityWrapper(NativeMethods.PriorityClass.PROCESS_MODE_BACKGROUND_END); * ; BACKGROUND_BEGIN = new ProcessPriorityWrapper(NativeMethods.PriorityClass.PROCESS_MODE_BACKGROUND_BEGIN); */ AllValues[0] = IDLE_PRIORITY_CLASS = new ProcessPriorityWrapper(NativeMethods.PriorityClass.IDLE_PRIORITY_CLASS);; AllValues[1] = new ProcessPriorityWrapper(NativeMethods.PriorityClass.BELOW_NORMAL_PRIORITY_CLASS); AllValues[2] = NORMAL_PRIORITY_CLASS = new ProcessPriorityWrapper(NativeMethods.PriorityClass.NORMAL_PRIORITY_CLASS);; AllValues[3] = new ProcessPriorityWrapper(NativeMethods.PriorityClass.ABOVE_NORMAL_PRIORITY_CLASS); AllValues[4] = new ProcessPriorityWrapper(NativeMethods.PriorityClass.HIGH_PRIORITY_CLASS); AllValues[5] = REALTIME_PRIORITY_CLASS = new ProcessPriorityWrapper(NativeMethods.PriorityClass.REALTIME_PRIORITY_CLASS);; }
private void cmbProcessPriority_SelectionChangeCommitted(object sender, EventArgs e) { var newValue = (ProcessPriorityWrapper)cmbProcessPriority.SelectedItem; /* * if (newValue == ProcessPriorityWrapper.REALTIME_PRIORITY_CLASS) * { * var newTimer = new Timer(); * { * var backColor = cmbProcessPriority.BackColor; * cmbProcessPriority.BackColor = Color.Red; * newTimer.Enabled = true; * newTimer.Interval = 1000; * newTimer.Tick += (p_sender, p_args) => * { * var localTimer = newTimer; * * cmbProcessPriority.BackColor = backColor; * localTimer.Enabled = false; * localTimer.Dispose(); * }; * } * * ProcessWrapper.ShowPriorityWarning(this); * } */ var operationResult = m_processWrapper.SetPriority(newValue.Value); if (false == operationResult) { cmbProcessPriority.SelectedItem = m_previousProcessPriority; } else { m_previousProcessPriority = newValue; } }