异步/等待VS的BackgroundWorker [英] Async/await vs BackgroundWorker

查看:93
本文介绍了异步/等待VS的BackgroundWorker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几天里我已经测试过的.NET 4.5和C#5的新功能。

In the past few days I have tested the new features of .net 4.5 and c# 5.

我喜欢它的新的异步/等待功能。早些时候,我曾使用<一个href=\"http://msdn.microsoft.com/en-us/library/vstudio/system.componentmodel.backgroundworker%28v=vs.100%29.aspx\">BackgroundWorker处理与响应性的UI背景较长时间的进程。

I like its new async/await features. Earlier I had used BackgroundWorker to handle longer processes in the background with responsive UI.

我的问题是:这些有不错的新功能后,我什么时候应该使用异步/的await而当<一个href=\"http://msdn.microsoft.com/en-us/library/vstudio/system.componentmodel.backgroundworker%28v=vs.100%29.aspx\">BackgroundWorker?这是常见的场景为?

My question is: after having these nice new features, when should I use async/await and when a BackgroundWorker? Which are the common scenarios for both?

推荐答案

异步/的await是用来取代结构,如的BackgroundWorker 。虽然你肯定的可以的,如果你想,你应该能够使用异步/的await,与其他几个TPL工具一起,以处理一切,是在那里使用它。

async/await is designed to replace constructs such as the BackgroundWorker. While you certainly can use it if you want to, you should be able to use async/await, along with a few other TPL tools, to handle everything that's out there.

由于这两个工作,把它归结为个人的preference为您使用的时候。什么是的的更快?什么是的的理解?

Since both work, it comes down to personal preference as to which you use when. What is quicker for you? What is easier for you to understand?

这篇关于异步/等待VS的BackgroundWorker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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