[quote=185052:@Michael Diehr]Michel, good question.
Have you done a lot of realtime UI programming? It makes sense when you imagine that there are other threads doing important tasks too.
Suppose you have an “earthquake monitor” app. It needs to monitor earthquakes, so that runs on background thread “A”. It’s important to capture all data.
But, this app allows you to configure the settings. You can save the settings. Say the user makes some changes, then clicks “Save”.
What should happen?
You could run the “Save” routine in the event loop. Works great, except thread A is blocked, and you miss some earthquake data.
Or, you could run the “Save” routine in Thread B, and just fire this off asynchronously from the Event loop (e.g. you return immediately from the Event loop, and other Events such as mouse clicks or menu handlers can fire). This works fine, until the user modifies the settings during the Save routine. That’s not good.
One logical solution: Let thread A run, and do the Save in Thread B, but, also, block the Event loop so that other UI is blocked until thread B finishes.
Conceptually, you are using the Event loop as a Semaphore.[/quote]
I would rather disable the button or menu item that initiate the save than the whole UI. Having a thread block another feels improper to me.
Earthquakes bad.1994 Northridge earthquake. My whole neighborhood shattered. Bad.