Spinner
A spinner (or other simple activity indicator) can be a helpful visualization of whether or not there's background activity. It'll be visible if the number of background tasks is non-zero. To track this, we can implement a simple counter in the application and update it using the StartTask() and StopTask() functions. A listener or channel would then tell the user interface element that the number of running tasks had changed so it can update the GUI by showing or hiding the visual element.
In a cloud-based application where a background task is using network connections, there's an added benefit: we can insert these task tracking function calls into the network request code. For example, we could update readStream() to call StartTask() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access