开发者

Does IEventAggregator subscribe multiple times?

开发者 https://www.devze.com 2023-04-01 11:27 出处:网络
If I have the following Microsoft.Practices.Prism.Events.IEventAggregator instan开发者_StackOverflow社区ce:

If I have the following Microsoft.Practices.Prism.Events.IEventAggregator instan开发者_StackOverflow社区ce:

eventAggregator.GetEvent<MyEvent>.Subscribe(SomeMethod);

and the above line of code is hit multiple times, does EventAggregator check if there is already a subscribtion or will this keep subscribing and fire multiple times (everytime) for a single Publish()?


It should subscribe multiple times. The Subscribe method returns a SubscriptionToken which should be distinct even if you use the call the Subscribe with the same method multiple times, allowing you to remove a distinct reference if you choose to do so.

0

精彩评论

暂无评论...
验证码 换一张
取 消