问题描述
我很新的线程。我启动一个线程是这样的:
I'm very new to threading. I start a thread like this:
Thread t_main;
t_main = new Thread(main_building_stuff);
t_main.Start();
和在某些时候,我想在main_building_stuff到虎视眈眈从网页的一些数据加载到。一个网页浏览器控制研究在主线程
And at some point, I want in the main_building_stuff to grap some data from an webpage that is loaded into an webbrowser controll in the main thread.
我这样做,随着这段代码:
I'm doing that with this piece of code:
HtmlElement lit = webBrowser1.Document.GetElementById("buildqueue");
但是,这将导致一个错误...
InvalidCastException的(指定的强制转换无效)
But that results in an error...InvalidCastException (specified cast is not valid)
什么是从web浏览器接收数据的正确方法?
What is the proper way to receive the data from the webbrowser?
推荐答案
有人说answerd的问题,给出了正确的答案。但由于某些原因,他删除了它,所以谢谢你,但我不记得你的名字......
Somebody that answerd the question, gave the right answer. But for some reason, he deleted it, so thank you, but i don't remember your name...
这是工作的一段代码:
webBrowser1.Invoke(new Action(() => {
HtmlElement lit = webBrowser1.Document.GetElementById("buildqueue");
result = "whatever";
}));
这篇关于线程和WebBrowser控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!