silverlight ClientHttp 请求性能缓慢
我可能在这里遗漏了一些东西,但我注意到在 silverlight 中使用 BeginGetResponse 时性能非常慢。
回调需要很长时间才能触发(10-20 秒),我发出的请求是针对大量资源的,但我预计回调会在标头解析后触发(基本上是立即的)。
如果我获取代码并在 .NET 4 上运行它,回调将立即触发。
以下是我在两种情况下使用的代码(在 .NET 4 中使用 WebRequest.Create ):
var url = @"insert http url to large resource here";
var req = WebRequestCreator.ClientHttp.Create(new Uri(url));
req.BeginGetResponse(r =>
{
var res = req.EndGetResponse(r);
Debug.WriteLine("Got response");
}, null);
例如,对于大小为 10MB 的资源,“得到响应”可能需要长达 10 秒的时间才能在 silverlight 中触发。
I may well be missing something here but I'm noticing very slow performance when using BeginGetResponse in silverlight.
It is taking a large period of time for the callback to fire (10-20 seconds), the requests I'm making are to large resources, but I expected the callback to fire once the headers had been parsed (essentially immediate).
If I take the code and run it on .NET 4 the callback is fired instantly.
Here is the code I'm using in both cases (bar using WebRequest.Create in .NET 4):
var url = @"insert http url to large resource here";
var req = WebRequestCreator.ClientHttp.Create(new Uri(url));
req.BeginGetResponse(r =>
{
var res = req.EndGetResponse(r);
Debug.WriteLine("Got response");
}, null);
In example, a resource that is 10MB in size, 'Got response' can take up to 10 seconds to fire in silverlight.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否在 BeginGetResponse 中下载 10MB 文件,这就是文件越大速度越慢的原因。文件越小,“得到响应”的速度就越快吗?
Is it downloading the 10MB file in the BeginGetResponse which is why it is slower the bigger the file is. Do smaller file 'get the response' back faster?