/// <summary> /// 用户账户验证的后台端 /// </summary> private void ThreadCheckAccount() { //定义委托 Action <string> message_show = delegate(string message) { Dispatcher.Invoke(new Action(() => { SetInformationString(message); })); }; Action start_update = delegate { Dispatcher.Invoke(new Action(() => { //需要该exe支持,否则将无法是实现自动版本控制 string update_file_name = AppDomain.CurrentDomain.BaseDirectory + @"软件自动更新.exe"; try { System.Diagnostics.Process.Start(update_file_name); Environment.Exit(0);//退出系统 } catch { MessageBox.Show("更新程序启动失败,请检查文件是否丢失,联系管理员获取。"); } })); }; Action thread_finish = delegate { Dispatcher.Invoke(new Action(() => { UISettings(true); })); }; // 启动密码验证 if (AccountLogin.AccountLoginServer( message_show, start_update, thread_finish, UserName, UserPassword, IsChecked, "wpf")) { //启动主窗口 Dispatcher.Invoke(new Action(() => { DialogResult = true; return; })); } }
/// <summary> /// 用户账户验证的后台端 /// </summary> private void ThreadCheckAccount() { // 定义委托 // 消息显示委托 Action <string> message_show = delegate(string message) { if (IsHandleCreated) { Invoke(new Action(() => { label_status.Text = message; })); } }; // 启动更新委托 Action start_update = delegate { if (IsHandleCreated) { Invoke(new Action(() => { // 需要该exe支持,否则将无法是实现自动版本控制 string update_file_name = Application.StartupPath + @"\软件自动更新.exe"; try { System.Diagnostics.Process.Start(update_file_name); Environment.Exit(0);//退出系统 } catch { MessageBox.Show("更新程序启动失败,请检查文件是否丢失,联系管理员获取。"); } })); } }; // 结束的控件使能委托 Action thread_finish = delegate { if (IsHandleCreated) { Invoke(new Action(() => { UISettings(true); })); } }; // 启动密码验证 if (AccountLogin.AccountLoginServer( message_show, start_update, thread_finish, textBox_userName.Text, textBox_password.Text, checkBox_remeber.Checked, "winform")) { // 启动主窗口 if (IsHandleCreated) { Invoke(new Action(() => { DialogResult = DialogResult.OK; return; })); } } }