用time控件啊,获取threadstate后,按指定时间间隔规定向界面刷新,线程必须是全局变量
成都创新互联公司专业为企业提供莱芜网站建设、莱芜做网站、莱芜网站设计、莱芜网站制作等企业网站建设、网页设计与制作、莱芜企业网站模板建站服务,十多年莱芜做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
用一个有退出条件的无限循环的sub也行。
线程开始就触发该过程,用无限循环来刷新状态,线程完成即退出无限循环。局部变量的线程也可以用这种方式。
不过用法要正确,否则会出问题。
Thread不会返回值的。你应该创建委托的,使用委托的异步方法
Dim funcInt32 As Func(Of String, Integer) = AddressOf GetList
Dim s As IAsyncResult = funcInt32.BeginInvoke("(参数)", Nothing, Nothing)
’在要获得结果的地方调用EndInvoke方法结束异步调用并获得结果。
Dim result As Int32 = funcInt32.EndInvoke(s)
public static string getXmlFile(String url, String paramList,string referer)
{
HttpWebResponse res = null;
string strResult = " ";
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET ";
req.KeepAlive = true;
req.Referer=referer;
//CookieContainer cookieCon = new CookieContainer();
//req.CookieContainer = cookieCon;
//req.CookieContainer.SetCookies(new Uri(url),cookieheader);
StringBuilder UrlEncoded = new StringBuilder();
res = (HttpWebResponse)req.GetResponse();
Stream ReceiveStream = res.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding( "gb2312 ");
StreamReader sr = new StreamReader( ReceiveStream, encode );
Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 );
while (count 0)
{
String str = new String(read, 0, count);
strResult += str;
count = sr.Read(read, 0, 256);
}
}
catch(Exception e)
{
strResult = e.ToString();
}
finally
{
if ( res != null )
{
res.Close();
}
}
return strResult;
}
多线程里调用就行了 费了好长时间才弄出来 我调试过了 能行 如果对你有用就给分吧