title: Operating a runtime webbrowser control from a background thread vb.net
body: <p>I'm trying to use a bunch of webbrowsers in some background threads. This works no problem when I use webbrowser controls that i have placed on the form in design view but now when they are created at runtime.</p>
  
  <p>I declare the webbrowsers array globally:</p>
  
  <pre><code>Dim webbroswers(-1) As WebBrowser
  </code></pre>
  
  <p>The following code is on the main thread:</p>
  
  <pre><code>ReDim Preserve webbroswers(somenum)
  
    For i = 0 To sumnum
  
              webbroswers(currentbrowsermax + i) = New WebBrowser
  
    Next
  </code></pre>
  
  <p>Then this code is run on the background thread:</p>
  
  <pre><code>If webbroswers(num).InvokeRequired Then
      webbroswers(num).Invoke(Sub() webbroswers(num).Navigate(someurl))
  Else
      webbroswers(num).Invoke(Sub() webbroswers(num).Navigate(someurl))
  </code></pre>
  
  <p>The program crashes at this point with the following error:</p>
  
  <blockquote>
    <p>Unable to get the window handle for the 'WebBrowser' control. Windowless ActiveX controls are not supported.</p>
  </blockquote>
  
  <p>Any help on this would be great. Also if anyone knows how to suppress script errors then I think this might help. I've tried: WebBrowser(num).ScriptErrorsSuppressed = True but this doesn't work (it doesn't work elsewhere in my code when running on the main thread either) Thanks!</p>