Skip to content

Priority

ZjzMisaka edited this page Dec 17, 2025 · 5 revisions

WorkPriority

WorkPriority signifies the priority level of the works that needs to be undertaken.
Works with higher priority (represented by higher numerical values) are executed first. This facilitates a more efficient and organized execution of works, particularly in situations where certain works are more critical or time-sensitive than others. By setting the WorkPriority, the order and speed of work execution in the applications can be effectively controlled.

powerPool.QueueWorkItem(() =>
{
    // Do something
}, new WorkOption()
{
    WorkPriority = 2
});

ThreadPriority

ThreadPriority pecifies the scheduling priority of a System.Threading.Thread.
However, handling this attribute requires a degree of caution. Modifying the ThreadPriority could potentially lead to problems such as thread starvation or priority inversion, which could detrimentally affect the application's performance or even cause it to become unresponsive. Therefore, it is important to tread carefully while setting the ThreadPriority, ensuring its implications are thoroughly understood.

powerPool.QueueWorkItem(() =>
{
    // Do something
}, new WorkOption()
{
    ThreadPriority = ThreadPriority.Highest
});

Clone this wiki locally