Class TaskPoolGlobalHook
- Namespace
- SharpHook
- Assembly
- SharpHook.dll
Represents a task pool-based implementation of IGlobalHook.
public sealed class TaskPoolGlobalHook : GlobalHookBase, IGlobalHook, IBasicGlobalHook, 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 on which the hook itself is running 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(int, GlobalHookType, IGlobalHookProvider?, bool)
Initializes a new instance of TaskPoolGlobalHook.
public TaskPoolGlobalHook(int parallelismLevel = 1, GlobalHookType globalHookType = GlobalHookType.All, IGlobalHookProvider? globalHookProvider = null, bool runAsyncOnBackgroundThread = false)
Parameters
parallelismLevelintThe parallelism level of event handlers.
globalHookTypeGlobalHookTypeThe global hook type.
globalHookProviderIGlobalHookProviderThe underlying global hook provider, or null to use the default one.
runAsyncOnBackgroundThreadbooltrue if RunAsync() should run the hook on a background thread. Otherwise, false.
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.
HandleHookEvent(ref UioHookEvent)
Handles the hook event.
protected override void HandleHookEvent(ref UioHookEvent e)
Parameters
eUioHookEventThe event to handle.