Communicating across modules with Prism?

試著忘記壹切 提交于 2021-02-08 15:25:52

问题


From following the Prism documentation it says there are four ways to communicate across modules -

  • Solution commanding
  • Region context
  • Shared services
  • Event aggregation

    1. Can I just chose one of these methods and apply it for all cross-module communcation? Or should I use different methods depending on the situation?
    2. In particular, in an application Im writing at the moment I have button in one module and when the user clicks it I want to start a thread in another module. Which method of communication would I use for this situation?

回答1:


Ans 1: Yes, you can use a single approach all-over. Most of the times it will be easier to do it that way.

Ans 2: I recommend you use Event Aggregation to do that. That way, you have a very loose coupling between the button click and the thread execution. That way, the listening module just has to be aware of a single event no matter where it was raised from.

Since, it is a single notification and not a bunch of inter-related notifications/communications, it is better to Aggregate an event rather than creating a Shared Service.



来源:https://stackoverflow.com/questions/8625290/communicating-across-modules-with-prism

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!