开发者

Slow Internet access from windows app, per load assemblies?

I writing (or trying to) an app in开发者_如何学Go c# .Net 4 all is working but two functions that make calls to the Internet are very slow the first time they are called!

XDocument xmlDoc = XDocument.Load(@"http://somedomain/somefile.xml");

this takes around 15-20 seconds the first time an about 1 the next!

I'm also using WebRequest in another place to do an HTTP POST and I have the same issue when I hit that code!

I assume it's the time taken to load and initialise the assemblies!?

Any way to preload them? or a better way to access the net?


There are workaround for this in both server and client.

If you are sure that the time is taken by the server to generate the XML, put an HTTPHandler in the server and use Output Caching to the XML.

In client side, you invoke a Thread and call the XDocument.Load to load the file in the thread while you do your rest of the loading. Once the data is loaded properly use a CallBack, an Event to ensure that the object can be accessed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜