Async&await on gui evenloop?

Hi, I’m learning rust and GUI develop on windows.
And I noticed someone meet this problem that program cost much CPU however sleep() can solve this because GetMessage() block the thread.
So I have a simple question that is async/await helpful on GetMessage() ?

The problem in your link was that they were simply rendering frames as fast as possible, which would obviously use a lot more power. In general most applications and games will limit the rate at which they render frames to no greater than the monitor’s refresh rate, sleeping as necessary. async and await are not some magical solution, and are merely a way of transforming code in certain ways to make it easier to read and write in some situations.

Windows UI stuff is very picky about only allowing you to manipulate something on its thread, so the best solution is to dedicate a thread to UI matters, while everything else can run asynchronously in the background on other threads.

1 Like