这是我的代码:
public void pobierzSuchary()
{
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new Uri("http://../michal/suchary.txt"));
}
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
ToastPrompt toast = new ToastPrompt
{
Background = new SolidColorBrush(Colors.Green),
Message = "Suchary zostały pobrane"
};
String[] sucharyTab = e.Result.Split('@');
MessageBox.Show(sucharyTab[1]);
..
}
按钮运行pobierzSuchary()并正在下载字符串,当我按下第二次按钮时出现问题。然后我在messagebox中看到旧值,但我在服务器上更改了字符串(手动)。我必须禁用应用程序并再次运行以查看新字符串
答案 0 :(得分:2)
这是因为Windows手机会自动缓存重复呼叫的值。
只需在您的网络客户端电话结尾附加一个随机数
即可像这样的东西
Random ran = new Random();
webClient.DownloadStringAsync(new Uri("http://../michal/suchary.txt?ran="+ran.next().toString()));