title: Web.ReadyState does not reach 'complete' stage
body: <p>First of all apologies for my lack of technical knowledge and probable miscommunication, I'm quite a newbie to C#.</p>
  
  <p>I've taken over a project which scrapes a number of webpages and saves them as .png files.</p>
  
  <pre><code>private void CaptureWebPage(string URL, string filePath, ImageFormat format)
  {
      System.Windows.Forms.WebBrowser web = new System.Windows.Forms.WebBrowser();
      web.ScrollBarsEnabled = false; 
      web.ScriptErrorsSuppressed = true; 
      web.Navigate(URL); 
  
      while (web.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete)
          System.Windows.Forms.Application.DoEvents();
      System.Threading.Thread.Sleep(5000);
  
      int width = web.Document.Body.ScrollRectangle.Width;
      width += width / 10;
      width = width &lt;= 300 ? 600 : width; 
  
  
      int height = web.Document.Body.ScrollRectangle.Height;
      height += height / 10;
  
      web.Width = width;
      web.Height = height;
  
      _bmp = new System.Drawing.Bitmap(width, height);
  
  
      web.DrawToBitmap(_bmp, new System.Drawing.Rectangle(0, 0, width, height));
      _bmp.Save(filePath, format);
  
      _bmp.Dispose();
  
  }
  </code></pre>
  
  <p>However, some of the pages (only a small few) cause the process to hang. Its not all the time, but fairly often. I've discovered the problem seems to be in the following part of code:</p>
  
  <pre><code>while (web.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete)
      System.Windows.Forms.Application.DoEvents();
  </code></pre>
  
  <p>It looks as though the web.ReadyState gets stuck at 'interactive' and never progresses to 'complete' so it just keeps looping.</p>
  
  <p>Is it possible to put in code that causes the process to restart for that page if the web.ReadyState = 'Interactive' for a certain amount of time, and if so what would the syntax be?</p>