我打电话给服务器api并等待响应。我只能在得到服务器响应后才能继续。但有些时候服务器响应只有在一段时间后才会收到,而我的标题栏显示“Not responding”消息。我该如何解决这个问题。没有响应显示在标题栏
我的代码块是
private string SubmitDocument(XmlDocument xmlinput, string URL)
{
try
{
// get the data from the xml document into a byte stream
Byte[] byteinput = System.Text.Encoding.UTF8.GetBytes(xmlinput.OuterXml);
// instantiate a web client
System.Net.WebClient myWebClient = new System.Net.WebClient();
myWebClient.Headers.Add("Content-Type", "text/xml");
byte[] responseArray = myWebClient.UploadData(URL, byteinput);
string responseString = Encoding.ASCII.GetString(responseArray);
return responseString;
}
catch(Exception ex)
{
return null;
}
}
感谢
`DoEvents`很少是这个问题的好答案... – 2009-08-03 10:56:28