Waiting for WebBrowser ajax content

The following should work,

while (Browser.Document.GetElementById("divid") == null) 
{ 
    Application.DoEvents();
    Thread.Sleep(200); 
}

The above worked for me...


Don't block the main thread's message pump. Since the browser is an STA component, xmlhttprequest won't be able to raise events from the background thread if you block the message pump. You can't navigate in a background thread. The Windows Forms wrapper of the webbrowser ActiveX does not support access from other threads than the UI thread. Use a timer instead.