线程内调取webBrowser1.DocumentText报错 我的程序1.线程 开启一个timer2.timer里string hehe=webBrowser1.DocumentText;//就报错求各位大哥帮帮忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 未处理 System.InvalidCastException Message="指定的转换无效。" Source="System.Windows.Forms" string hehe=webBrowser1.DocumentText;这句会报这个错?确认是这句吗?不应该啊 string hehe=webBrowser1.DocumentText.ToString(); public MyHtmlForm() { InitializeComponent(); this.WebBroswer.Navigate("http://www.baidu.com"); timer = new Timer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = 1000; timer.Enabled = true; timer.Start(); } void timer_Tick(object sender, EventArgs e) { string s = this.WebBroswer.DocumentText; }测试一切正常啊 先开启一个线程,然后线程里开启TIMER,TIMER里再使用 string s = this.WebBroswer.DocumentText; private void button13_Click(object sender, EventArgs e) { t = new Thread(new ThreadStart(OpenTime1)); t.Start(); } private void OpenTime1() { timer2.Interval = 1000; timer2.Start(); Application.Run(); } private void timer2_Tick(object sender, EventArgs e) { string cuan = this.webBrowser1.DocumentText;} private void button13_Click(object sender, EventArgs e) {OpenTime1(); //为什么用线程,直接这样不行吗 } private void OpenTime1() { timer2.Interval = 1000; timer2.Start(); // Application.Run(); } private void timer2_Tick(object sender, EventArgs e) { string cuan = this.webBrowser1.DocumentText; } 直接这样,单用一个TIMER,CS程序有时候会卡住 你的timer是不是开太早了,最好在webBrowser1的DocumentCompleted后去执行timer.start,或者在使用webBrowser1.DocumentText前判断webBrowser1的状态是不是已经加载完成。 IE6 怎么设置为禁用?! 怎么循环得到多个值并输出到DIV 发布后的数据库连接从SQL2000变成了SQL2005连接 求解DirectoryEntry访问AIA(颁发机构信息访问)路径 高手帮帮忙 客户端提交数据到服务器的问题 紧急救援::C#调用API的问题,参与有分,大家帮帮我,谢谢! Validation of viewstate MAC failed. sql server 系统数据库的备份(包括定时备份)与还原 字符串转换问题 代码Framework从2.0到3.5 dataGridView 取值?
Message="指定的转换无效。"
Source="System.Windows.Forms"
这句会报这个错?确认是这句吗?不应该啊
{
InitializeComponent();
this.WebBroswer.Navigate("http://www.baidu.com");
timer = new Timer();
timer.Tick += new EventHandler(timer_Tick);
timer.Interval = 1000;
timer.Enabled = true;
timer.Start();
} void timer_Tick(object sender, EventArgs e)
{
string s = this.WebBroswer.DocumentText;
}
测试一切正常啊
先开启一个线程,然后线程里开启TIMER,TIMER里再使用
string s = this.WebBroswer.DocumentText;
{
t = new Thread(new ThreadStart(OpenTime1));
t.Start(); } private void OpenTime1()
{
timer2.Interval = 1000;
timer2.Start();
Application.Run();
} private void timer2_Tick(object sender, EventArgs e)
{
string cuan = this.webBrowser1.DocumentText;
}
{
OpenTime1(); //为什么用线程,直接这样不行吗
}
private void OpenTime1()
{
timer2.Interval = 1000;
timer2.Start();
// Application.Run();
}
private void timer2_Tick(object sender, EventArgs e)
{
string cuan = this.webBrowser1.DocumentText;
}
直接这样,单用一个TIMER,CS程序有时候会卡住