protected override void OnStartup(StartupEventArgs e) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // ManualResetEvent acts as a block. It waits for a signal to be set. _resetSplashCreated = new ManualResetEvent(false); // Create a new thread for the splash screen to run on _splashThread = new Thread(ShowSplash); _splashThread.SetApartmentState(ApartmentState.STA); _splashThread.IsBackground = true; _splashThread.Start(); // Wait for the blocker to be signaled before continuing. This is essentially the same as: while(ResetSplashCreated.NotSet) {} _resetSplashCreated.WaitOne(); base.OnStartup(e); if (MabiCommerce.Properties.Settings.Default.UpdateCheck) { Task.Factory.StartNew(CheckForUpdates); } Environment.CurrentDirectory = Path.GetDirectoryName(typeof(MainWindow).Assembly.Location); Erinn erinn; try { erinn = Erinn.Load(@"Data", Splash.ReportProgress); } catch (Exception ex) { throw new Exception("Failed to load MabiCommerce's data.", ex); } Splash.ReportProgress(1.0, "Loading main window..."); var mw = new MainWindow(erinn); mw.Show(); }
public MainWindow(Erinn e) { InitializeComponent(); DataContext = Erinn = e; }