Hacker News new | ask | show | jobs
by db48x 814 days ago
That’s the key; the thread showing the UI mustn’t do any real work. Instead do the work on another thread and then communicate the status back to the UI thread. Exactly how you do that is up to you; there are plenty of different ways to do it that depend on other choices you’ve made, such as whether you’re using async or not, what async runtime you use, etc, etc.

The very simplest way to do it might be for the UI thread to send the work thread an Arc<AtomicBool>. The work thread can set the bool to true when the work is finished. The UI thread can branch on the value of the bool each frame to decide what to draw. Job done.