private void StartTest_Click(object sender, RoutedEventArgs e) { GetInidata("C:\\" + "PeojectIni\\" + ProjiectListBox.SelectedValue.ToString() + ".ini", GetUiData(resultlistbox)); var a = ProjiectListBox.SelectedValue; if (a != null) { if (ReadIniFile("C:\\PeojectIni\\" + a.ToString() + ".ini") != null) { Application.Current.Dispatcher.Invoke((Action)(() => { (this.DataContext as MainWindowModel).SysProject = ReadIniFile("C:\\PeojectIni\\" + a.ToString() + ".ini"); AllAutoTest at = new AllAutoTest(ReadIniFile("C:\\PeojectIni\\" + a.ToString() + ".ini")) { WindowState = WindowState.Maximized }; at.Show(); })); } else { Application.Current.Dispatcher.Invoke(() => { ShowHide("方案不存在\t\n或数据错误"); }); } } this.Close(); }
private void MainWindow_OpenAutoTest(byte[] ISopen) { ThreadPool.QueueUserWorkItem(delegate { SynchronizationContext.SetSynchronizationContext(new System.Windows.Threading.DispatcherSynchronizationContext(Application.Current.Dispatcher)); SynchronizationContext.Current.Post(pl => { Views.AllAutoTest al = new Views.AllAutoTest(ISopen); al.Show(); }, null); }); }