110,552
社区成员
发帖
与我相关
我的任务
分享
for(int i=0;i<100;i++)
{
string url="http://www.123.com?s="+i;
WebBrowser.Navigate(url);
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
//(怎么样判断?WebBrowser.ReadyState != WebBrowserReadyState.Complete 会出现异常“指定的转换无效”)
{
Application.DoEvents();
};
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
void work(object obj)
{
ISynchronizeInvoke isi = (ISynchronizeInvoke)obj;
isi.Invoke(new mywork(working), new object[] { "http://www.baidu.com" });
}
void working(string url)
{
for (int i = 0; i < 1; i++)
{
//string url = "http://www.123.com?s=" + i;
//string url = "http://www.baidu.com";
webBrowser1.Navigate(url);
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
//(怎么样判断?WebBrowser.ReadyState != WebBrowserReadyState.Complete 会出现异常“指定的转换无效”)
{
Application.DoEvents();
};
}
}
delegate void mywork(string url);
private void button1_Click(object sender, EventArgs e)
{
ISynchronizeInvoke isi = this;
System.Threading.Thread td = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(work));
td.Start(isi);
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
void work(object obj)
{
ISynchronizeInvoke isi = (ISynchronizeInvoke)obj;
isi.Invoke(new MethodInvoker(working), null);
}
void working()
{
for (int i = 0; i < 1; i++)
{
//string url = "http://www.123.com?s=" + i;
string url = "http://www.baidu.com" ;
webBrowser1.Navigate(url);
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
//(怎么样判断?WebBrowser.ReadyState != WebBrowserReadyState.Complete 会出现异常“指定的转换无效”)
{
Application.DoEvents();
};
}
}
private void button1_Click(object sender, EventArgs e)
{
ISynchronizeInvoke isi = this;
System.Threading.Thread td = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(work));
td.Start(isi);
}
}
}
WebRequest wr = WebRequest.Create("www.123.com");
HttpWebResponse resp = (HttpWebResponse)wr.GetResponse();
//...