8000 Work Group · ZjzMisaka/PowerThreadPool Wiki · GitHub
[go: up one dir, main page]

Skip to content

Work Group

ZjzMisaka edited this page Oct 17, 2025 · 18 revisions

A Group can be set for a work using WorkOption.Group.

powerPool.QueueWorkItem(() =>
{
    // Do something
}, new WorkOption()
{
    Group = "GroupName"
});

This way, the execution of works can be controlled in batches through the already set group.

powerPool.GetGroup("GroupName").Wait();
powerPool.Wait(powerPool.GetGroupMemberList("GroupName"));

Group Object

PowerPool.GetGroup(string groupName) will return a group object, which have funcions for control the works belonging to the group.

Properties

[Get only]
Group name

string Name;

Group Control

The group object has the following functions for group control, similar to the pool and work control.

name summary result
Add(WorkID workID) Add work to group. Returns false if the work does not exist.
Modifies WorkOption.Group.
Remove(WorkID workID) Remove work from group. Returns false if work does not exist, or if the work does not belong to the group
Wait(bool helpWhileWaiting = false) Wait until all the work belonging to the group is done.
Wait(CancellationToken cancellationToken, bool helpWhileWaiting = false) Wait until all the work belonging to the group is done.
WaitAsync(bool helpWhileWaiting = false) Wait until all the work belonging to the group is done.
WaitAsync(CancellationToken cancellationToken, bool helpWhileWaiting = false) Wait until all the work belonging to the group is done.
Fetch(bool removeAfterFetch = false, bool helpWhileWaiting = false) Fetch the work result. Return a list of work result
Fetch(CancellationToken cancellationToken, bool removeAfterFetch = false, bool helpWhileWaiting = false) Fetch the work result. Return a list of work result
Fetch(bool removeAfterFetch = false, bool helpWhileWaiting = false) Fetch the work result. Return a list of work result
Fetch(CancellationToken cancellationToken, bool removeAfterFetch = false, bool helpWhileWaiting = false) Fetch the work result. Return a list of work result
Fetch(Func<ExecuteResult, bool> predicate, bool removeAfterFetch = false, bool helpWhileWaiting = false) Fetch the work result. Return a list of work result
FetchAsync(bool removeAfterFetch = false, bool helpWhileWaiting = false) Fetch the work result. Return a list of work result
FetchAsync(CancellationToken cancellationToken, bool removeAfterFetch = false, bool helpWhileWaiting = false) Fetch the work result. Return a list of work result
FetchAsync(bool removeAfterFetch = false, bool helpWhileWaiting = false) Fetch the work result. Return a list of work result
FetchAsync(CancellationToken cancellationToken, bool removeAfterFetch = false, bool helpWhileWaiting = false) Fetch the work result. Return a list of work result
Stop() Stop all the work belonging to the group. Return false if no thread running
ForceStop() Force stop all the work belonging to the group. Return false if no thread running
Pause() Pause all the work belonging to the group. Return a list of IDs for work that doesn't exist
Resume() Resume all the work belonging to the group. Return a list of IDs for work that doesn't exist
Cancel() Cancel all the work belonging to the group. Return a list of IDs for work that doesn't exist

Clone this wiki locally

0