我需要在WPF启动代码中混合 parallelism
和async
个概念:
protected override async void OnStartup(StartupEventArgs e)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += currentDomain_UnhandledException;
ViewModelLocator locator = (ViewModelLocator)App.Current.Resources["Locator"];
SimpleIoc.Default.GetInstance<MainViewModel>();
SimpleIoc.Default.GetInstance<IndexViewModel>();
Func<Task> fsignHandler = async () => { await Task.Run(() => { SimpleIoc.Default.GetInstance<Fiche_SignaletiqueViewModel>(); Debug.WriteLine("fsign loaded"); }); };
Func<Task> formationHandler = async () => { await Task.Run(() => { SimpleIoc.Default.GetInstance<FormationsViewModel>(); }); };
await Task.WhenAll(fsignHandler(), formationHandler());
}
我遇到了这些问题:
fsign loaded
。MVVM light
及其IoC SimpleIOC
:当我导航到菜单Fiche_Signaletique
(Fiche_SignaletiqueViewModel
作为视图模型时) Fiche_SignaletiqueViewModel 将被实例化,表明永远不会执行fsignHandler
!!!! 我需要知道: