Keep app responsive during long task

后端 未结 10 2214
逝去的感伤
逝去的感伤 2020-12-09 13:57

A certain form in our application displays a graphical view of a model. The user can, amongst loads of other stuff, initiate a transformation of the model that can take quit

10条回答
  •  悲&欢浪女
    2020-12-09 14:36

    I think your folly is thinking of the transformation as a single task. If user input is required as part of the calculation and the input asked for depends on the caclulation up to that point, then I would refactor the single task into a number of tasks.

    You can then run a task, ask for user input, run the next task, ask for more input, run the next task, etc.

    If you model the process as a workflow, it should become clear what tasks, decisions and user input is required.

    I would run each task in a background thread to keep the user interface interactive, but without all the marshaling issues.

提交回复
热议问题