What's the difference between calling .NET methods asynchronously by using:
使用以下方法异步调用.NET方法之间的区别是什么:
vs.
vs.
- Specific object asynchronous methods (WebClient, for example)
特定对象异步方法(例如WebClient)
I assume the difference between the first two and the third one is that some objects (WebClient in this case) natively support asynchronous calling via dedicated methods, so there's no need to use the BeginInvoke or IAsynchResult approaches?
我假设前两个和第三个之间的区别在于某些对象(在这种情况下是WebClient)本身支持通过专用方法进行异步调用,因此不需要使用BeginInvoke或IAsynchResult方法吗?
1 个解决方案
#1
1
The first two approaches actually go hand-in hand. The BeginInvoke method returns an IAsyncResult which you later use for a call to EndInvoke later. The third method hides a lot of this complexity by allowing you to give it a delegate to call when it has completed its task (usually a bit easier to use).
前两种方法实际上是齐头并进的。 BeginInvoke方法返回一个IAsyncResult,稍后您可以将其用于对EndInvoke的调用。第三种方法隐藏了很多这种复杂性,允许您在完成任务时给它一个委托来调用(通常更容易使用)。
#1
1
The first two approaches actually go hand-in hand. The BeginInvoke method returns an IAsyncResult which you later use for a call to EndInvoke later. The third method hides a lot of this complexity by allowing you to give it a delegate to call when it has completed its task (usually a bit easier to use).
前两种方法实际上是齐头并进的。 BeginInvoke方法返回一个IAsyncResult,稍后您可以将其用于对EndInvoke的调用。第三种方法隐藏了很多这种复杂性,允许您在完成任务时给它一个委托来调用(通常更容易使用)。