Sometimes the user starts an extended technical operation that takes a while to execute. In these cases, it's usually nice to display some kind of progress bar, along with information about which task is being executed right now.
In order to avoid close-coupling the UI and the logic layers, it's usually best to have the communication occur via some kind of proxy. That is, the back-end should not be manipulating its own UI elements, or even interacting with the intermediary layer directly.
Obviously, there has to be some call-back somewhere to make this work. I've generally implemented it in one of two ways:
Pass a mutable object to the back-end, and have the back-end make changes to it on progress. The object notifies the front-end when a change occurs.
Pass a call-back function of the form
ProgressObject -> unitthat the back-end invokes. In this case, the back-end constructs the
ProgressObjectand it's completely passive. It must construct a new object every time it wants to report progress, I assume.
What are the drawbacks and advantages of these methods? Is there an agreed-upon best method to use? Are there different circumstances for their use?
Are there completely different techniques of reporting progress that I've overlooked?