In Deltashell we would like to use threading to increase application responsiveness during long operations. Threading might be a good way to do this. If we want to use threading and don't want to use locks when we access shared resources (model etc) we should make sure all model modifications are done in the same thread. This can be done by letting an operation run asynchronous and letting the forms thread handle the results.Like the following picture:

During the integration part the UI will not be responsive but this won't be a problem as long as this operation does not take too long.

In DS we could have a ASyncModel and a Synchmodel (simple/normal). The ASynchmodel will we passed a synchronizationcontext (ISynchronizeInvoke) so it can do it's model results synchronously. The simplemodel could be run synchronous altogher so it will be simpler to implement. For the ASynchModel developers will have to make sure the model modifications are done synchonously to prevent threading problem.

The big plus of this design is that the multi-threading does not get scattered throught the application. The model will still need to be made read-only so the worker thread won't face an altered model during calculation. This can be done by making the (relevant) views readonly during model run.

Please comment and review.

  • No labels