473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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));
t.SetApartmentState(ApartmentState.STA);
t.Start();
}

private void DoIt()
{
WebBrowser wb = new WebBrowser();
wb.DocumentCompleted += new
WebBrowserDocumentCompletedEventHandler(wb_Documen tCompleted);
wb.Navigate("http://www.google.com");
}

private void wb_DocumentCompleted(object sender, EventArgs e)
{
//THE CODE NEVER GETS HERE
string text = ((WebBrowser)sender).Document.Body.InnerText;
this.strTest = text;
}

Jan 4 '06 #1
0 1794

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Luis Ferrao | last post by:
Hi, My Windows Forms application uses the WebBrowser control to open an Excel file since OLE objects are gone in .Net. The application is actualy a clone of the one found in the MS Knowledge...
4
by: Jay | last post by:
Hi all, May i know if there is any way by which we can render a given HTML inside .NET Windows Forms? We had the Web Browser controls in Visual Studio 6. Is there a follow-up of that in...
7
by: Robert May | last post by:
I have an application that uses the Ax web browser object. When I call the IHTMLElement.click() method on an input button (<input type="submit"> or <input type="button">), the click fires...
2
by: daniel.manges | last post by:
I'm working on a .NET application using Google Maps, but since the page is updated with Javascript, I think I need to use Javascript to get directions from the page. Does anybody know how to...
1
by: Eggy | last post by:
Hi. I have an application that should download files from internet. The problem is the protocol is HTTPS. So I have a System.Windows.Forms.WebBrowser which allows the user to log in to the HTTPS...
2
by: Qiang | last post by:
Hi, Anybody knows how to convert an instance of SHDocVw.WebBrowser to System.Windows.Forms.WebBrowser? Or is it possible? thanks, Qiang
16
by: Daniela Roman | last post by:
Hello, can someone tell me the main differences between the web and windows based applications? thank you
1
by: Joe | last post by:
HI Trying to figure out the difference between these 2 browser I am embedding a MS office Document (Word/Excel) in a WebBrowser on a Form With AxSHDocVw I can do the following to save the...
3
by: sonicwrx | last post by:
Am I missing something? I have a form with a browser control and a button. The code under the button is: private void btnGo_Click(object sender, EventArgs e) { wbScrape.Navigate(@"http://...
1
by: mici8 | last post by:
I am trying to use WebBrowser WebBrowser1 = new System.Windows.Forms.WebBrowser(); in a class library. I have a vb.net code in an application and i need to change to c# class Library. I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.