public async Task StartAsync() { MainViewModel viewModel = new MainViewModel(); viewModel.CloseRequested += viewModel_CloseRequested; EventHandler windowClosed = (sender, e) => { viewModel.RequestClose(); }; SplashScreen splashScreen = new SplashScreen(); //not disposable, but I'm keeping the same structure { splashScreen.Closed += windowClosed; //if user closes splash screen, let's quit splashScreen.Show(); await viewModel.InitializeAsync(); MainWindow mainForm = new MainWindow(); mainForm.Closed += windowClosed; mainForm.DataContext = viewModel; mainForm.Show(); splashScreen.Owner = mainForm; splashScreen.Closed -= windowClosed; splashScreen.Close(); } }
public async Task StartAsync() { MainViewModel viewModel = new MainViewModel(); viewModel.CloseRequested += viewModel_CloseRequested; EventHandler windowClosed = (sender, e) => { viewModel.RequestClose(); }; SplashScreen splashScreen = new SplashScreen(); //not disposable, but I'm keeping the same structure { splashScreen.Closed += windowClosed; //if user closes splash screen, let's quit splashScreen.Show(); await viewModel.InitializeAsync(); MainWindow mainForm = new MainWindow(); mainForm.Closed += windowClosed; mainForm.DataContext = viewModel; mainForm.Show(); splashScreen.Owner = mainForm; splashScreen.Closed -= windowClosed; splashScreen.Close(); } }
public async Task StartAsync() { MainViewModel viewModel = new MainViewModel(); viewModel.CloseRequested += viewModel_CloseRequested; await viewModel.InitializeAsync(); MainWindow mainForm = new MainWindow(); mainForm.Closed += (sender, e) => { viewModel.RequestClose(); }; mainForm.DataContext = viewModel; mainForm.Show(); }
public async Task StartAsync() { MainViewModel viewModel = new MainViewModel(); viewModel.CloseRequested += viewModel_CloseRequested; await viewModel.InitializeAsync(); //this will be on a threadpool thread instead of a ui thread, and won't work //it will throw an exception because it's not an STA thread MainWindow mainForm = new MainWindow(); mainForm.Closed += (sender, e) => { viewModel.RequestClose(); }; mainForm.DataContext = viewModel; mainForm.Show(); }
public async Task StartAsync() { MainViewModel viewModel = new MainViewModel(); viewModel.CloseRequested += viewModel_CloseRequested; await viewModel.InitializeAsync(); MainWindow mainForm = new MainWindow(); mainForm.Closed += (sender, e) => { viewModel.RequestClose(); }; mainForm.DataContext = viewModel; mainForm.Show(); }
public async Task StartAsync() { MainViewModel viewModel = new MainViewModel(); viewModel.CloseRequested += viewModel_CloseRequested; await viewModel.InitializeAsync(); //this will be on a threadpool thread instead of a ui thread, and won't work //it will throw an exception because it's not an STA thread MainWindow mainForm = new MainWindow(); mainForm.Closed += (sender, e) => { viewModel.RequestClose(); }; mainForm.DataContext = viewModel; mainForm.Show(); }