Best Practice for BackGroundWorker in WinForms using an MVP architecture

前端 未结 2 528
再見小時候
再見小時候 2021-01-15 11:28

I am working on a winforms project. I am implementing an MVP architecture. I have some processing intensive jobs running at the presenter (Reading from file system and perfo

相关标签:
2条回答
  • 2021-01-15 11:55

    Work should not be summoned by the presenter - add another model unit that does the work and call the work (can be via the gui) from the controller.

    (Have the view raise a Work event, handled by the controller, which summons the backgroundworker and calls the view on updates/completion).

    0 讨论(0)
  • 2021-01-15 12:09

    I think the view should be as passive as possible. The presenter should handle itself the events from the BackgroundWorker and translate this information to the view (e.g. update a list shown in a grid). To the view, this request should be no different than if the data had come directly from the presenter.

    0 讨论(0)
提交回复
热议问题