public void GetLogin(object obj) { LoginParm loginparm = obj as LoginParm; Data.GetLoginResult = Protocol.DoLogin(loginparm.Username, loginparm.Password); OnReadParamEvent(Data.GetLoginResult.ToString());//触发事件 }
private void OnLogin() { if (txt_Username.Text == "" || txt_password.Text == "") { MessageBox.Show(this, "用户名或密不能为空!", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } LoginParm loginparm = new LoginParm(); loginparm.Username = txt_Username.Text; loginparm.Password = txt_password.Text; ThreadEx threadex = new ThreadEx(); threadex.Start(new ParameterizedThreadStart(threadex.GetLogin), (Object)loginparm, new EventHandler(GetLogin), this); button1.Enabled = false; }