Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blocking dispatch_thread_events function #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mbartlett21
Copy link

I had problems with the dispatch_thread_events_with_callback function either letting me have a responsive UI with high CPU usage or having to add a sleep of some sort into my callback (which made the window not work properly with focus).
This PR adds a dispatch_thread_events_blocking_with_callback function that mirrors the dispatch_thread_events function in that it blocks for new messages, but it adds a callback after each message is handled. This results in low CPU usage.

My use case:
I have a program that runs a local Futures executor in the main thread, but I don't want to block the UI. I was previously using the dispatch_thread_events_with_callback function, but it resulted in high CPU usage until I added a WaitMessage to the end of my callback. However, when I added that, it would then not work properly when trying to bring the window into focus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant