Skip to content
Discussion options

You must be logged in to vote

Hi! Thanks for asking!

Firstly, regarding Microsoft DI - you can just register the global hook like that:

services.AddSingleton<IGlobalHook, TaskPoolGlobalHook>();
// or
services.AddSingleton<IGlobalHook>(s => new TaskPoolGlobalHook());

Secondly, regarding Avalonia - I think the best way would be to start the global hook in the App class (e.g. in the OnFrameworkInitializationCompleted method). You can call RunAsync and just ignore its result since you don't need to wait for the hook to stop. Also, you can configure the global hook to run on a background thread - this way it won't impede the application from stopping when you close the main window (or the last window, depending on your set…

Replies: 5 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@sandreas
Comment options

Answer selected by sandreas
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@TolikPylypchuk
Comment options

Comment options

You must be logged in to vote
1 reply
@TolikPylypchuk
Comment options

Comment options

You must be logged in to vote
1 reply
@TolikPylypchuk
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants