Search code examples
delphiomnithreadlibrary

How to get Worker from the IOmniTaskControl?


Is it possible to get the Worker object from a task handle of the type IOmniTaskControl? For example, on a terminate event, I want to log details of which worker was affected.


Solution

  • IOmniTaskControl doesn't provide such functionality.

    When you create new task, add its implementor and the IOmniTaskControl reference to some list/dictionary and then in OnTerminate look into that list/dictionary. (And don't forget to remove that entry from the list/dictionary or task controller won't be destroyed as the list/dictionary would keep a reference to it.)