我可以通过这种方式从网站获取 html 代码:
public void Test()
{
WebClient client = new WebClient();
client.DownloadStringCompleted +=
new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(new Uri("http://testUrl.xml"));
}
void client_DownloadStringCompleted(object sender,
DownloadStringCompletedEventArgs e)
{
string html = e.Result;
//Now do something with the string...
}
但我需要每 30 秒更新一次 html,所以我写道:
public void TestMain()
{
DispatcherTimer Timer = new DispatcherTimer()
{
Interval = TimeSpan.FromSeconds(30)
};
Timer.Tick += (s, t) =>
{
Test();
};
Timer.Start();
}
我更改了xml,但我得到了相同的html,怎么了?