I have an issue where my web browser is not responding when looping javascript through a while loop, so I can't cancel this loop or do anything with my web browser.
I'm triggering javascript with checkbox and I can't uncheck the checkbox after I checked it because my Browser is not responding while looping
Here is the code:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
while (checkBox1.Checked == true)
{
System.Threading.Thread.Sleep(1000);
CurBrowser.GetMainFrame().ExecuteJavaScriptAsync("var elems = document.getElementsByClassName('VotingButton VotingButton--upvote btn-white'); elems[0].click();");
System.Threading.Thread.Sleep(1000);
CurBrowser.GetMainFrame().ExecuteJavaScriptAsync("var elems1 = document.getElementsByClassName('task-skip-submit js-next-question'); elems1[0].click();");
}
}