Skip to content

Timeout

ZjzMisaka edited this page Aug 26, 2025 · 2 revisions

PowerPoolOption.TimeoutOption: Represents the maximum amount of time that all works in a thread pool can run collectively before they are terminated. It includes a duration in milliseconds (ms) and a boolean flag for forcefully stopping the work.

PowerPoolOption.DefaultWorkTimeoutOption: Represents the default maximum amount of time a work in the pool can run before it is terminated. It includes a duration in milliseconds (ms) and a boolean flag for forcefully stopping the work.

PowerPool powerPool = new PowerPool();
powerPool.PowerPoolOption = new PowerPoolOption()
{
    TimeoutOption = new TimeoutOption() { Duration = 10000, ForceStop = false },
    DefaultWorkTimeoutOption = new TimeoutOption() { Duration = 3000, ForceStop = false },
};

WorkOption.TimeoutOption: Represents the maximum amount of time a specific work can run before it is terminated. It includes a duration in milliseconds (ms) and a boolean flag for forcefully stopping the work.

powerPool.QueueWorkItem(() => 
{
    // Do something
}, new WorkOption()
{
    TimeoutOption = new TimeoutOption() { Duration = 2000, ForceStop = true }
});

Clone this wiki locally