Jump to content

DPStano

Members
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. same AV i see in logs from OnTerminated FTask := CreateTask( procedure(const Task: IOmniTask) begin end).Unobserved.OnTerminated(OnThreadTermination).Join(FTaskGroup) ... procedure TFoo.OnThreadTermination(const Task: IOmniTaskControl); begin FTaskGroup.Remove(FTask); //AV Here ... but TFoo holding FTask And FTaskGroup reference is waiting for WaitForAll in its destructor destructor TFoo.Destroy; begin // stop all threads FCancellationToken.Signal; FTaskGroup.WaitForAll; it looks like OnTerminated will be somehow called after WaitForAll
  2. I can't reproduce it myself, just see it in logs from testers my code looks like sample below https://gist.github.com/Sorien/d62c81f853f831f309c3d71bbc80209d (stripped sample) AV/Null pointer exception happens at the first line of invoke method https://gist.github.com/Sorien/d62c81f853f831f309c3d71bbc80209d#file-unit12-pas-L59
  3. I'm getting multiple reports of AccessViolations inside Task.Invoke function call, it seems that Task.Invoke can/will be called after thread termination unlike TThread.Queue that will not. is that correct behavior, how to wait for the end of Task.Invoke execution? @Primož Gabrijelčič
  4. yes it works but without clearing taskgroup i can have taskgroup with like 100k finished tasks which won't be very effective at first i was searching for something like CreateTask( procedure(const Task: IOmniTask) begin try // do some work finally GlobalTaskGroup.Remove(Task) end end).Unobserved.Join(GlobalTaskGroup); but IOmniTaskGroup is not a group of IOmniTask but a group of IOmniTaskControl but i found solution OnTerminated can give me IOmniTaskControl so i'll unregister task from group there
  5. I have multiple tasks 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 (some of them are already finished) 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 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.
×