You are implementing a GUI where a long-running calculation is performed upon clicking a button. To prevent the GUI from freezing (not responding), what is the best practice approach?
Offloading the task to a background thread keeps the main thread free to process GUI events.
Why this answer
Running blocking operations in the main thread freezes the event loop; threading is required to keep the GUI responsive.