Prism:EventAggregator阻止WPF应用程序关闭

Prism:EventAggregator阻止WPF应用程序关闭,wpf,prism,eventaggregator,Wpf,Prism,Eventaggregator,我正在使用Microsoft.Practices.Prism.PubSubEvents.IEventAggregator默认实现连接视图模型以响应应用程序关闭事件,如下所示: public class MainViewModel { public MainViewModel( IEventAggregator eventAggregator, Shell shell) { _shell.Closing += OnApplicationClosing;

我正在使用Microsoft.Practices.Prism.PubSubEvents.IEventAggregator默认实现连接视图模型以响应应用程序关闭事件,如下所示:

public class MainViewModel
{

     public MainViewModel( IEventAggregator eventAggregator, Shell shell)
     {
        _shell.Closing += OnApplicationClosing;
        _eventAggregator = eventAggregator;
    }

   private void OnApplicationClosing(object sender, CancelEventArgs e)
        {           
            //TODO: investigate why this is locking application.
            _eventAggregator.GetEvent<ApplicationClosingEvent>().Publish(new CancelEventArgs());           
        }
}
public类主视图模型
{
公共主视图模型(IEventAggregator事件聚合器,Shell)
{
_shell.Closing+=OnApplicationClosing;
_eventAggregator=eventAggregator;
}
Application Closing上的私有无效(对象发送方,CancelEventArgs e)
{           
//TODO:调查这是锁定应用程序的原因。
_eventAggregator.GetEvent().Publish(新的CancelEventArgs());
}
}
当我连接此事件时,应用程序在关闭时挂起。WPF应用程序正在使用.NET 4.5和Prism v5.0.0.0以及Prism.PubSubEvents 1.0.0


以前有人看到过吗?

可能是某个订阅服务器在同步处理此事件时进行了长时间的同步操作很可能,因为当我注释掉订阅代码时,应用程序关闭正常。显然我的架构有问题。这些长时间运行的操作不能在后台线程上完成吗?没有长时间运行的操作。问题是,当其中一个事件订阅者试图使用null键访问字典时,引发了null异常。这导致了坠机。再次谢谢。你应该删除这个问题。因为这似乎无关紧要