private void onConnect(object sender, RoutedEventArgs e) { Ipstring = this.txtServerIP.Text; wp_hx_Client.Leave_Out(); //与主服务器断开连接 Boolean key = Client.Connect(this.txtServerIP.Text); if (key) { Debug.WriteLine("wwwwwwwwww", DateTime.Now.ToLongTimeString()); //Dispatcher.BeginInvoke(() => this.NavigationService.Navigate(new Uri("/Information.xaml", UriKind.Relative))); this.NavigationService.Navigate(new Uri("/Information.xaml", UriKind.Relative)); } else { MessageBox.Show("连接失败!!!"); Client.Leave_Out(); } }
// 激活应用程序(置于前台)时执行的代码 // 此代码在首次启动应用程序时不执行 private void Application_Activated(object sender, ActivatedEventArgs e) { Client.Connect(Connect.Ipstring); // 确保正确恢复应用程序状态 }