简体   繁体   English

WebClient DownloadStringCompleted仅触发一次

[英]WebClient DownloadStringCompleted only fires once

I got this code: 我得到以下代码:

private void LoadXML()
{
    WebClient myWebClient = new WebClient();
    myWebClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(myWebClient_DownloadStringCompleted);
    myWebClient.DownloadStringAsync(new Uri(strXMLPath));

}

private void myWebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    //Do stuff                       
}

myWebClient_DownloadStringCompleted is only fired first time I call LoadXML() . myWebClient_DownloadStringCompleted仅在我第一次调用LoadXML()时触发。 There is no errors on the xml file im trying to get, so I should be expecting a result. 尝试获取的xml文件没有错误,因此我应该期待结果。 What am I missing? 我想念什么?

I managed to narrow the problem down. 我设法缩小问题的范围。 I had the silverlight object inside an asp:updatepanel , when I moved the silverlight object outside the updatepanel, things started to work. 我将silverlight对象放在asp:updatepanel ,当我将silverlight对象移到updatepanel之外时,事情开始起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM