WebClient DownloadStringCompleted只触发一次

时间:2011-12-20 10:49:44

标签: c# silverlight

我收到了这段代码:

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仅在我第一次拨打LoadXML()时被解雇。我试图获取的xml文件没有错误,所以我应该期待一个结果。我错过了什么?

1 个答案:

答案 0 :(得分:0)

我设法将问题缩小了。我在asp:updatepanel内部有一个silverlight对象,当我将silverlight对象移到更新面板之外时,事情开始起作用了。