Jump to content
dexter

OnTerminated with Thread Pool

Recommended Posts

Hi,

I'm using the GlobalOmniThreadPool like this:

  CreateTask(
    procedure(const aTask: IOmniTask)
    begin
      FProvider.Execute(Self);
    end)
    .OnTerminated(
      procedure(const aTask: IOmniTaskControl)
      begin
        FEvents.FireThreadEndEvent();
      end
    )
    .Join(FTaskGroup)
    .Schedule;

During FProvider.Execute() some DB resources are alocated (within task's thread).

 

Questions:

1. For some reason OnTerminated() is not called at all, even when program is finished.

2. When OnTerminated is called - will it be called from thread's context, so I'll release DB resources. If not - is there any event call from thread's context at the end of execution?

 

 

 

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
×