代表们的分歧VS BackgroundWorker的? [英] Differences of Delegates vs BackgroundWorker?

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

问题描述

谁能解释代表和BackgroundWorker的区别呢?在这种情况下,BackgroundWorker的比代表更有效?因为我们有异步委托有什么用BackGroungWorker的需求。

Can anyone explain the difference between Delegates and BackgroundWorker?In which case Backgroundworker is more efficient than Delegate?Since we are having asynchronous delegate what is the need to use BackGroungWorker.

推荐答案

的BackgroundWorker

BackgroundWorker的类允许您在一个单独运行的操作,专用线程。

The BackgroundWorker class allows you to run an operation on a separate, dedicated thread.

代表

一个委托是一种类型,它定义了一个方法签名。 ......代表们用来传递方法作为参数传递给其他方法。

A delegate is a type that defines a method signature. ... Delegates are used to pass methods as arguments to other methods.

使用哪一个问题无关与效率。


The question of which one to use has nothing to do with efficiency.

的BackgroundWorker 是简化了使用线程的包装,你可以使用异步委托也很好,但正确地管理它们要困难得多。或者,从MSDN:

BackgroundWorker is a wrapper that simplifies working with threads, you can use async delegates just as well, but managing them correctly is much more difficult. Or, from MSDN:

当你想要一个负责任的UI,你都面临着这样的操作相关的长时间延误,BackgroundWorker的类提供了一个方便的解决方案。

When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker class provides a convenient solution.

这篇关于代表们的分歧VS BackgroundWorker的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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