我正在使用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());
}
}
当我连接此事件时,应用程序会在关闭时挂起。 WPF应用程序使用.NET 4.5和Prism v5.0.0.0与Prism.PubSubEvents 1.0.0.0
之前有人见过这个吗?