gabr42/OmniThreadLibrary

[Q] TaskGroup

Sorien opened this issue · 4 comments

I have multiple task like

  var Task := CreateTask(
    procedure(const Task: IOmniTask)
    begin
    end).Unobserved.Join(GlobalTaskGroup);

  Parallel.Start(Task , Parallel.TaskConfig.CancelWith(GlobalCancellationToken));

they can run for various times from seconds to minutes and some tasks can even run multiple times at once, and I need to terminate them and wait for termination all living task at some point

  GlobalCancellationToken.Signal;
  GlobalTaskGroup.WaitForAll();

so the question is how to properly manage task group to keep just living tasks in it?

I'm not sure I understand the question. Doesn't that work automatically?

BTW, a better place for open questions and discussions is the OTL Forum: https://en.delphipraxis.net/forum/32-omnithreadlibrary/

ok, let me finish this one at github, I'll post at your forum other question, i don't see any code how could TaskGroup remove task after its termination, it will keep reference until the task is explicitly removed by calling TaskGroup.remove.

Please move this to the forum too. I don't really understand what doesn't work for you and I would need a code example.