摘要: 当我们在界面线程中进行I/O操作的时候,经常会导致界面锁死。为了解决这个问题,就需要将I/O操作异步执行。在.Net 4.5中针对异步编程有了新的做法,它新推出了两个关键字 async 和 await。下面我们就以读取网络数据为例,一步一步来看看它能带给我们的优势。1. 一般的同步实现方式public string DownloadSync() { StringBuilder sb = new StringBuilder(); using (WebClient client = new WebClient()) { for (int i = 1... 阅读全文
posted @ 2013-03-22 18:39 CanMusic 阅读(312) 评论(0) 推荐(0) 编辑