Prism CompositePresentationEvent 触发两次

编程入门 行业动态 更新时间:2024-10-24 20:19:43
本文介绍了Prism CompositePresentationEvent 触发两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的基础架构中,我发布了一个事件

In my infrastructure i publish a event

this.eventAggregator.GetEvent<ReportAddedEvent>().Publish(report);

报表是一个对象

在我的控制器中我订阅了这个事件

In my controller i subscribe to this event

this.eventAggregator.GetEvent<ReportAddedEvent>().Subscribe(this.OnReportAdded);

我的问题是事件触发了两次.整个代码中没有其他地方发布事件,所以我确定该事件不会在其他地方触发,我可以看到它只触发一次.

My problem is that the event fires twice. There is no other place in the entire code where the event is published so im certain that the event is not fired somewhere else and i can see it only fires once.

任何人都有建议或解决问题的方法或知道问题出在哪里.

Anyone have a suggestion or have a solution to problem or knows where the problem lies.

推荐答案

我觉得是代码的问题

this.eventAggregator.GetEvent<ReportAddedEvent>().Subscribe(this.OnReportAdded);

订阅 ReportAddedEvent 执行两次.

to subscribe to the ReportAddedEvent is executed two times.

您应该检查(通过使用调试器和线路上的断点)它是否执行了多次.

You should check (by using a debugger and a breakpoint on the line) if it executes more than once.

更多推荐

Prism CompositePresentationEvent 触发两次

本文发布于:2023-11-27 13:00:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638184.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两次   Prism   CompositePresentationEvent

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!