471,334 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

Windows.Forms.WebBrowser Multi-Threaded

I need to use a Windows.Forms.WebBrowser in a separate thread. (I'm
not using the GUI, I just want to navigate to a page and get the
..Document.Body.InnerText property of the WebBrowser - maybe there is
another way to do this?).

To make the instance, I set the thread to run in STA mode.

However, the DocumentCompleted event never gets called. It works fine
if I don't using threading, but in multi-threading, the event for
DocumentCompleted never happens.


private void button2_Click(object sender, EventArgs e)
Thread t = new Thread(new ThreadStart(DoIt));

private void DoIt()
WebBrowser wb = new WebBrowser();
wb.DocumentCompleted += new
WebBrowserDocumentCompletedEventHandler(wb_Documen tCompleted);

private void wb_DocumentCompleted(object sender, EventArgs e)
string text = ((WebBrowser)sender).Document.Body.InnerText;
this.strTest = text;

Jan 4 '06 #1
0 1660

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jay | last post: by
2 posts views Thread by daniel.manges | last post: by
3 posts views Thread by sonicwrx | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.