/// <summary> /// Change the scheduling priority for the I/O operations for a specific thread /// </summary> /// <param name="thread">Handle to the thread</param> /// <param name="priority">I/O Priority</param> public static void SetPriority(IntPtr thread, ThreadsPriority priority) { if (priority == ThreadsPriority.THREAD_MODE_BACKGROUND_BEGIN || priority == ThreadsPriority.THREAD_MODE_BACKGROUND_END) { throw new ArgumentException("Process mode background can only set for current process"); } try { SetThreadPriority(thread, priority); } catch { } }
static extern bool SetThreadPriority(IntPtr hThread, ThreadsPriority nPriority);
/// <summary> /// Change the scheduling priority for the I/O operations for the current thread /// </summary> /// <param name="priority">I/O Priority</param> public static void SetPriority(ThreadsPriority priority) { try { SetThreadPriority(GetCurrentThread(), priority); } catch { } }
/// <summary> /// Change the scheduling priority for the I/O operations for a specific thread /// </summary> /// <param name="thread">Handle to the thread</param> /// <param name="priority">I/O Priority</param> public static void SetPriority(IntPtr thread, ThreadsPriority priority) { if (priority == ThreadsPriority.THREAD_MODE_BACKGROUND_BEGIN || priority == ThreadsPriority.THREAD_MODE_BACKGROUND_END) throw new ArgumentException("Process mode background can only set for current process"); try { SetThreadPriority(thread, priority); } catch { } }