title: ASP.NET - WebBrowser - making it wait for a second or two
body: <p>I am using a Webbrowser in ASP.NET to login to a betting site and place a bet.</p>
  
  <p>Once team is found and its click method raised, a side frame/window is loaded by javascript with a textbox to enter the bet ammount.</p>
  
  <p>I've tried :</p>
  
  <pre><code>var stakeTextboxElement = doc.GetElementById("stake");
  stakeTextboxElement.Focus();
  stakeTextboxElement.InnerText = "3";
  webbrowser.navigate("javascript: placeBet();"); //they use javascript
  </code></pre>
  
  <p>This gives me an error that my bid is not high enough (when it is). From what i can tell, its navigating too fast and not reading the InnerText as "3";</p>
  
  <p>I've done the exact same scenario in Windows Forms and instead of setting InnerText, i do </p>
  
  <pre><code>SendKeys.Send("3"); 
  webbrowser.navigate("javascript: placeBet();");
  </code></pre>
  
  <p>Same Error. But this works if i add 'Application.DoEvents();' just before the navigate. Doing the same does not work for the InnerText example.</p>
  
  <p>From what i can tell, i have to tell webbrowser to continue running for a second or two so it reads the textbox with text inside.</p>