I am using webbrowser control to parse html.

I used to have this code that works just fine

vb.net Code:
  1. Public Shared Sub putHtmlIntoWebBrowser(ByVal html As String)
  2.             'WebBrowser.DocumentText = html
  3.             WebBrowser.Document.OpenNew(True)
  4.             Dim noscriptHtml = removeScript(html)
  5.             appendToTextFile(noscriptHtml + vbNewLine, "laststring.html", Scripting.IOMode.ForWriting)
  6.             WebBrowser.ScriptErrorsSuppressed = True
  7.             WebBrowser.Document.Write(noscriptHtml)
  8.  
  9.         End Sub

After that I sort of manipulate the webbrowser control.

Then I modify my program. Before the code is always run from the main UI thread. Now each thread can run the code (with synclock of course).

Somehow it no longer works. webbrowser.document is simply not accessible.