protected override void OnStartup(StartupEventArgs e) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); base.OnStartup(e); LoadingWindow loadingWindow = new LoadingWindow(); loadingWindow.Show(); ModelLoader loader = new ModelLoader(loadingWindow); Task.Factory.StartNew(() => { loader.LoadUserSettings(); loader.TryToConnect(); modelContainer = loader.GetModelConatiner(); this.Dispatcher.Invoke(() => { MainWindow window = new MainWindow(); MainViewModel MainViewModel = new MainViewModel(modelContainer); window.DataContext = MainViewModel; this.MainWindow = window; loadingWindow.Close(); window.Show(); //modelContainer.jetsonClient.StartTelemetry(2); }); }); }