private void txtVc_TextChanged(object sender, EventArgs e) { if (txtVc.Text.Length == 4) { string code = txtVc.Text.Trim(); Thread t = new Thread(() => { if (VcHelper.CheckVc(StaticValues.MyCookies, code, token)) { this.BeginInvoke(new MethodInvoker(delegate() { aft.code = code; this.DialogResult = DialogResult.OK; })); } else { this.BeginInvoke(new MethodInvoker(delegate() { txtVc.Clear(); ShowVc(); lbMsg.Text = "验证码输入错误!"; })); } }); t.IsBackground = true; t.Start(); } }
private void LoadVc() { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(delegate() { imgVc.Image = Images.VcLoding; })); } else { imgVc.Image = Images.VcLoding; } Thread t = new Thread(() => { string code = string.Empty; Image img = VcHelper.GetVcImage(StaticValues.OrderVcUrl, ref code, ref StaticValues.MyCookies, ti.Token); if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(delegate() { txtVc.Text = code; imgVc.Image = img; })); } else { txtVc.Text = code; imgVc.Image = img; } }); t.IsBackground = true; t.Start(); }
private void LoadVc() { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(delegate() { imgVc.Image = Images.VcLoding; toolStripMsg.Text = "正在加载验证码..."; })); } else { imgVc.Image = Images.VcLoding; toolStripMsg.Text = "正在加载验证码..."; } Thread t = new Thread(() => { Stopwatch sw = new Stopwatch(); sw.Start(); string code = string.Empty; Image img = VcHelper.GetVcImage(StaticValues.LoginVcUrl, ref code, ref StaticValues.MyCookies); sw.Stop(); this.BeginInvoke(new MethodInvoker(delegate() { txtVc.Text = code; imgVc.Image = img; toolStripMsg.Text = "验证码加载成功,耗时:" + sw.ElapsedMilliseconds + "ms"; })); }); t.IsBackground = true; t.Start(); }
public void ShowVc() { Thread thread = new Thread(() => { string code = string.Empty; var img = VcHelper.GetVcImage(StaticValues.OrderVcUrl, ref code, ref StaticValues.MyCookies, token); if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(delegate() { this.imgVc.Image = img; if (code.Length == 4) { txtVc.Text = code; } else { txtVc.Text = ""; } })); } else { this.imgVc.Image = img; if (code.Length == 4) { txtVc.Text = code; } else { txtVc.Text = ""; } } }); thread.IsBackground = true; thread.Start(); }