使用 WebClient 的 Silverlight 后台线程 [英] Silverlight Background Thread using WebClient
本文介绍了使用 WebClient 的 Silverlight 后台线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 WebClient
从我的网络服务异步获取信息:
I'm using a WebClient
to get infos asynchronously from my web service :
wc.DownloadStringCompleted += DownloadStringCompleted;
wc.DownloadStringAsync(service);
我工作正常,但我认为 DownloadStringCompleted
方法正在 UI 线程上工作,并且由于我在那里进行了大量解析,我的页面需要几秒钟才能出现.但是,由于我有如此固定的数据和进度条,我不介意它立即出现.
I works fine, but I think the DownloadStringCompleted
method is working on the UI Thread, and since i'm doing a lot of parsing there, my page takes a few seconds to appear. However, since I have so fixed data and a progress bar, I would'nt mind have it appearing instantly.
我该怎么做?
谢谢!
推荐答案
使用 HttpWebRequest
而不是 WebClient
.HWR 不会在 UI 线程上返回,因此不会阻止它更新.
Use HttpWebRequest
rather than WebClient
. HWR doesn't return on the UI thread and so doesn't block it from updating.
这篇关于使用 WebClient 的 Silverlight 后台线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文