Closed demberto closed 1 year ago
Hello, I am not sure I understand your question. The listener is meant to be used in a separate thread. You should then be in control of this separate thread and you can then freely terminate it at any time. The listeners implemented up to now do not need to be "terminated gracefully", if this is what you are asking.
Hi, If large performance decrease with this thread, I think it would be better to be able to terminate a thread when don't need to listen to the changes to the OS's theme.
Hi, If large performance decrease with this thread, I think it would be better to be able to terminate a thread when don't need to listen to the changes to the OS's theme.
The current implementation uses the synchronous version of RegNotifyChangeKeyValue
. So it blocks the thread until the value is changed. So the only performance hit is whenever the theme actually changes. No polling is done.
The listener is meant to be used in a separate thread. You should then be in control of this separate thread and you can then freely terminate it at any time. The listeners implemented up to now do not need to be "terminated gracefully", if this is what you are asking.
I am new to threads, it seems discouraged to forcefully stop a thread.
I am new to threads, it seems discouraged to forcefully stop a thread.
This is true and by no means I was suggesting to randomly kill threads. What I am saying is that darkdetect
only provides functions (listener
) that can be used to continuously monitor the GUI settings. It is then left to the user how to use them, e.g. whether they want to encapsulate them in separate threads/processes or run them in the main thread. From our side, the code in the existing implementations of listener
can be safely interrupted.
if you wish to encapsulate your listener in an interruptible thread, I would suggest to implement your own thread handling, for example as suggested here: https://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread
Current Windows implementation doesn't allow breaking out of the infinite while loop