Trying to get to close application but not closing thread. #23
-
|
Hi, I'm trying to use your code for my maui spreadhsheet project but unfortunately it will not run as I intend it to. The code works fine and everything while the application is running but when I try to close the window, the application or thread still seems to be running so I believe the hook.dispose() code is not disposing the key handlers properly. This is my code, please let me know if I am doing something wrong. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hi! Thanks for using SharpHook! As far as I can see the problem is in this code: await hook.RunAsync();
hook.Dispose();The Actually, there's an issue in SharpHook itself. The hook runs in a separate thread - that thread should be a background thread, and it isn't. Thanks for the catch, I'll fix that in the next version, but for now you should call |
Beta Was this translation helpful? Give feedback.
-
|
Got it thanks boss!
…On Sat, Oct 22, 2022, 1:51 PM Tolik Pylypchuk ***@***.***> wrote:
Hi! Thanks for using SharpHook!
As far as I can see the problem is in this code:
await hook.RunAsync();hook.Dispose();
The Dispose method is never actually going to be called. In the code
above you need to dispose to stop awaiting RunAsync, but RunAsync will
finish only after disposing. You need to call Dispose in another place -
some code that gets called when the application is about to stop, like a
window closed event handler. I don't have any experience with MAUI, so I
can't help with the specifics.
Actually, there's an issue in SharpHook itself. The hook runs in a
separate thread - that thread should be a background thread, and it isn't.
Thanks for the catch, I'll fix that in the next version, but for now you
should call Dispose when the application exists.
—
Reply to this email directly, view it on GitHub
<#23 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYJDR2PM7SKLWTNTWNQF4RDWERATJANCNFSM6AAAAAARKQTI4Y>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Hi! Thanks for using SharpHook!
As far as I can see the problem is in this code:
The
Disposemethod is never actually going to be called. In the code above you need to stop awaitingRunAsyncto dispose, butRunAsyncwill finish only after disposing. You need to callDisposein another place - some code that gets called when the application is about to stop, like a window closed event handler. I don't have any experience with MAUI, so I can't help with the specifics.Actually, there's an issue in SharpHook itself. The hook runs in a separate thread - that thread should be a background thread, and it isn't. Thanks for the catch, I'll fix that in the ne…