How to organize an indication of the status of the task, with minimal interaction with the user interface? For example, the program performs a long calculation (possibly in a separate thread), and the user displays the progress bar in the GUI . I thought to create some intermediate object that will be passed to the task. And this, let's call it ProgressMonitor will send a message to the interface that the process is in ProgressMonitor . In general, the task being performed should not be aware of the GUI . It is desirable that the GUI know less about the task, ideally you only need to execute the StartTask function, and all the work will be performed by the task.

Can anyone know a different solution? Is there a design pattern for this case? Just in case I will add that I write on Java . I use JavaFX as a library for GUI .

  • one
    similar to the MVC + Observer pattern for notifying GUI about the state of the process - Gorets
  • Well, in fact, with this ProgressMonitor, I am implementing something like an Observer. - delphist007 pm
  • Well, if you need an indication ... take the whole process as 100% share how much you need and notify you when progress is made - Gorets
  • I can handle the definition of process readiness :) Here the whole question is precisely in the architecture of the interaction between the process and the GUI. I thought, you never know, there is an opportunity to do something else. - delphist007
  • and how can you do differently? if there is a measurable value, you can read it (for example, wait 15 seconds, copy 1 GB, copy 500 files). then you need to do the gui with a listener and the "rendition" will send events about the status update (1 second has passed, 1 file has been copied, 1 MB has been copied). if you have a task with non-transferable runtime, then it is better to just have a dialogue like: "wait for the user and look at our beautiful modal dialogue with a rotating pimp / hypno lab" - jmu

1 answer 1

If with minimal interaction, then it is necessary that by default the interface should consider that everything is going right, and show the operation indicator, and in logic to build in a condition or timer that would record a malfunction and only in the event of a failure would inform the interface about problems with logic only in case of failure, if necessary, I can throw an example in the evening.