这段代码应该等到我单击按钮后,如果条件没有单击任何按钮,它将继续执行。为什么会这样?
TaskCompletionSource<bool> _tcs;
public async Task gCaptcha()
{
string s = webBrowser1.DocumentText;
if (s.Contains(captchaPageTxt.Text))
{
//MessageBox.Show(captchaPageTxt.Text);
MessageBox.Show(new Form() { TopMost = true }, "please solve the captcha you have " + captchaSolveWaitTime.Text + " " +"seconds");
_tcs = new TaskCompletionSource<bool>();
await _tcs.Task // Here I want to wait until button3 clicked or checkbox1.checked. Then it need to continue with if condition etc.
if (captchaCompleted.Checked)
{
return;
}
}
}
void ButtonClicked(object sender, EventArgs e)
{
_tcs.SetResult(false);
}