Jump to content
DPStano

[Q] OmniThreadLibry AV at Task.Invoke

Recommended Posts

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č

Edited by DPStano

Share this post


Link to post

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

 

Edited by DPStano

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×