【发布时间】:2012-07-08 18:03:12
【问题描述】:
我的方法是这样的。 (Grabbed from here)
private void inetConvert() {
byte[] buf = new byte[1024];
string result;
string xeString = String.Format("http://www.xe.com/ucc/convert.cgi?Amount=1&From={0}&To={1}", srcCurrency, dstCurrency);
System.Net.WebRequest wreq = System.Net.WebRequest.Create(new Uri(xeString));
System.Net.WebResponse wresp = wreq.GetResponse();
Stream respstr = wresp.GetResponseStream();
int read = respstr.Read(buf, 0, 10240); // Error
result = Encoding.ASCII.GetString(buf, 0, read);
curRateLbl.Text= result;
}
问题是,当应用程序执行这个应用程序在挂起大约 4-5 秒后得到这个屏幕
我错过了什么?
【问题讨论】:
-
如果您有followed my advice and used
WebClient,则无需担心缓冲区大小。
标签: c# winforms networking