使用WebClient的Silverlight背景线程 [英] Silverlight Background Thread using WebClient

查看:76
本文介绍了使用WebClient的Silverlight背景线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WebClient从Web服务异步获取信息:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆