private async Task <MainWindowViewModel> InitializeAsync() { return(await Task.Run(async() => { Trace.AutoFlush = true; var sysname = System.Environment.MachineName; if (sysname == "JAKE-PC") { ConfigurationManager.AppSettings.Set("BatchTestSystem", "BTS1"); } else if (sysname == "DESKTOP-GQQ0M3J") { ConfigurationManager.AppSettings.Set("BatchTestSystem", "BTS2"); } Debug.WriteLine("sysname: " + sysname); await InstrumentService.CreateCoordinatorAsync(); await OriginService.CreateControllerAsync(); await DataProcessingService.CreateLEDCalculatorAsync(); if (Debugger.IsAttached) { Properties.Settings.Default.Reset(); } var dBConnectionManager = new DBConnectionManager(); ctx = new DeviceBatchContext(); Task[] initTasks = new Task[2]; initTasks[0] = LoadDirectoryTreeView(); initTasks[1] = UpdateIPAddress(); await Task.WhenAll(initTasks); Trace.TraceInformation("Initialized MainWindowViewModel"); return this; }).ConfigureAwait(false)); }