Class TaskPoolGlobalHook
- Namespace
- SharpHook
- Assembly
- SharpHook.dll
Represents a task pool-based implementation of IGlobalHook.
public sealed class TaskPoolGlobalHook : GlobalHookBase, IGlobalHook, IDisposable
- Inheritance
-
TaskPoolGlobalHook
- Implements
- Inherited Members
Remarks
The event handlers will run with the specified parallelism level on separate threads inside the default thread pool for tasks. This way the hook itself will not be blocked if the handlers are long-running. The exception is the HookDisabled event which will run on the same thread that called the Dispose() method since at that point it doesn't matter anymore that the hook is not blocked.
Setting SuppressEvent inside the handlers will have no effect as they are run on other threads.
Constructors
TaskPoolGlobalHook()
Initializes a new instance of TaskPoolGlobalHook.
public TaskPoolGlobalHook()
Remarks
Calling this constructor is the same as passing Sequential to the other constructor.
- See Also
TaskPoolGlobalHook(IGlobalHookProvider)
Initializes a new instance of TaskPoolGlobalHook.
public TaskPoolGlobalHook(IGlobalHookProvider globalHookProvider)
Parameters
globalHookProvider
IGlobalHookProviderThe underlying global hook provider.
Exceptions
- ArgumentNullException
globalHookProvider
is null.
- See Also
TaskPoolGlobalHook(IGlobalHookProvider, TaskPoolGlobalHookOptions)
Initializes a new instance of TaskPoolGlobalHook.
public TaskPoolGlobalHook(IGlobalHookProvider globalHookProvider, TaskPoolGlobalHookOptions options)
Parameters
globalHookProvider
IGlobalHookProviderThe underlying global hook provider.
options
TaskPoolGlobalHookOptionsThe options of the hook which include its parallelism level.
Exceptions
- ArgumentNullException
globalHookProvider
oroptions
is null.
- See Also
TaskPoolGlobalHook(TaskPoolGlobalHookOptions)
Initializes a new instance of TaskPoolGlobalHook.
public TaskPoolGlobalHook(TaskPoolGlobalHookOptions options)
Parameters
options
TaskPoolGlobalHookOptionsThe options of the hook which include its parallelism level.
Exceptions
- ArgumentNullException
options
is null.
- See Also
Methods
Dispose(bool)
Destoys the global hook.
protected override void Dispose(bool disposing)
Parameters
Remarks
After calling this method, the hook cannot be started again. If you want to do that, create a new instance of IGlobalHook.
Exceptions
- HookException
Stopping the hook has failed.
- See Also
HandleHookEvent(ref UioHookEvent)
Handles the hook event.
protected override void HandleHookEvent(ref UioHookEvent e)
Parameters
e
UioHookEventThe event to handle.
- See Also