private void AfterUserCheck(IAsyncResult result) { #region DLUserCheck dl_do = (DLUserCheck)result.AsyncState; if (!this.InvokeRequired) { return; } if (dl_do.EndInvoke(result)) { this.Invoke(new MethodInvoker(() => { _iconStatus._systemNotifyIcon.Text += "\r\nNO:" + _User.userid; this.Hide(); UserMainWindow mainwindow = new UserMainWindow(); mainwindow._IconController = new icon.IconController(); mainwindow._IconController.Bind(_iconStatus); mainwindow.Show(); _iconStatus.BindToWindow(mainwindow); })); } else { this.Invoke(new MethodInvoker(() => { ExtMessage.Show("帐号异常!"); })); } #endregion }
private void btnUserLogin_Click(object sender, EventArgs e) { #region //验证UI接收输入是否正确?? //开启登录时动态变化UI?? //此处要异步开启登录请求 CheckFormatValid(); DLUserCheck gd = new DLUserCheck(UserLogonRequest); //异步请求中传入callback方法控制变化UI的最终结果? //其实上述方法应该返回bool类型,以确定返回登录是否成功。 AsyncCallback callbak = new AsyncCallback(AfterUserCheck); gd.BeginInvoke(callbak, gd); //登录成功则本窗口隐藏,主视图为UserMainWindow #endregion }