title: Waiting for WebBrowser ajax content
body: <p>I want to pause the execution of my thread until a particular div has been loaded via ajax into a WebBrowser instance. Obviously I can continuously check for the presence of this div doing something like:</p>
  
  <pre><code>while (Browser.Document.GetElementById("divid") == null) { Thread.Sleep(200); }
  </code></pre>
  
  <p>However, sleeping the thread that the Browser is in between loops only blocks the browser from actually loading the content in the first place. It seems, therefore, that I need to execute the <code>Browser.Navigate</code> method in a separate thread - I can then continue to check/wait for the presence of the div whilst the WebBrowser instance continues loading the URL I asked it to.</p>
  
  <p>My attempts at this, however, have failed and I'd value any input on how I should go about this. I thought simply dispatching a new thread with <code>new Thread(() =&gt; { Browser.Navigate(url); });</code> would work but after doing so, nothing loads and the Browser.ReadyState remains as 'Uninitialized'. I presume I'm misunderstanding how to go about properly threading procedures like this with C# and would value some advice!</p>