The OtlHooks unit allows your code to hook into internal OmniThreadLibrary processes. Currently, you can register notification methods which are called when a thread is created/destroyed, a pool is created/destroyed, or an unhandled exception ‘escapes’ from a task.
Exception notifications
Exception filter allows your code to be notified when an unhandled exception in a task occurs. You can also prevent exception from being stored in the IOmniTask.FatalException property.
Call RegisterExceptionFilter to register a custom exception filter.
Call UnregisterExceptionFilter to remove custom exception filter.
Exception filter can use application-specific logging code to log detailed information about application state. It can also free the exception object e and set it to nil, which will prevent this exception to be stored in the FatalException property.
If the filter sets continueProcessing to false, further custom exception filters won’t be called. Filters are always called in the order in which they were registered.
Thread notifications
Thread notifications allow your code to be notified when a thread is created or destroyed inside the OmniThreadLibrary. This allows OmniThreadLibrary to cooperate with application-specific exception-logging code.
Call RegisterThreadNotification to register a thread notification method.
Call UnregisterThreadNotification to unregister such method.
Notification method is always called in the context of the thread being created/destroyed.
For example, the following code fragment registers/unregisters OmniThreadLibrary threads with an application-specific thread logger.
Pool notifications
Pool notifications allow your code to be notified when a thread pool is being created or destroyed. This allows the application to modify pool parameters on the fly.
Call RegisterPoolNotification to register a pool notification method.
Call UnregisterPoolNotification to unregister such method.
You can, for example, use pool notification mechanism to set Asy_OnUnhandledWorkerException property whenever a thread pool is created.