Table of Contents

Class EventLoopGlobalHook

Namespace
SharpHook
Assembly
SharpHook.dll

Represents an implementation of IGlobalHook which dispatches events to an event loop running on a separate dedicated thread.

public sealed class EventLoopGlobalHook : GlobalHookBase, IGlobalHook, IBasicGlobalHook, IDisposable
Inheritance
EventLoopGlobalHook
Implements
Inherited Members

Remarks

The event handlers will run on a separate thread. 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 another thread.

Constructors

EventLoopGlobalHook(GlobalHookType, IGlobalHookProvider?, bool)

Initializes a new instance of EventLoopGlobalHook.

public EventLoopGlobalHook(GlobalHookType globalHookType = GlobalHookType.All, IGlobalHookProvider? globalHookProvider = null, bool runAsyncOnBackgroundThread = false)

Parameters

globalHookType GlobalHookType

The global hook type.

globalHookProvider IGlobalHookProvider

The underlying global hook provider, or null to use the default one.

runAsyncOnBackgroundThread bool

true if RunAsync() should run the hook on a background thread. Otherwise, false.

Methods

BeforeRun()

Starts the event loop.

protected override void BeforeRun()

Dispose(bool)

Disposes of the global hook, stopping it if it is running, and completing the event loop.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true if the method is called from the Dispose() method. Otherwise, false.

Exceptions

HookException

Stopping the hook has failed.

HandleHookEvent(ref UioHookEvent)

Handles the hook event.

protected override void HandleHookEvent(ref UioHookEvent e)

Parameters

e UioHookEvent

The event to handle.

See Also