Skip to content

Timeout

ZjzMisaka edited this page Sep 8, 2023 · 1 revision

PowerPoolOption.Timeout: 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.DefaultWorkTimeout: 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()
{
    Timeout = new TimeoutOption() { Duration = 10000, ForceStop = false },
    DefaultWorkTimeout = new TimeoutOption() { Duration = 3000, ForceStop = false },
};

WorkOption.Timeout: 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()
{
    Timeout = new TimeoutOption() { Duration = 2000, ForceStop = true }
});