/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Sb_Authentication_Click(object sender, EventArgs e) { Sb_Authentication.Enabled = false; Sb_Cancel.Enabled = true; Xtc_Tabs.Enabled = false; var flag = false; try { var token = _cts.Token; while (!flag) { await Task.Run(async() => { flag = await _api.Login(Cam_Camera.TakeSnapshot()); }, token); if (!flag) { continue; } Cam_Camera.Stop(); ShowLoadForm(); } } catch (Exception exception) { LogHelper.Error(exception.ToString()); } }
private void Sb_Cancel_Click(object sender, EventArgs e) { _cts.Token.Register(() => { XtraMessageBox.Show("已停止识别!"); }); _cts.Cancel(true); Cam_Camera.Stop(); Sb_Cancel.Enabled = false; Sb_Authentication.Enabled = true; Xtc_Tabs.Enabled = true; }