gpt4 book ai didi

c# - 异步委托(delegate)调用 (ADI) 与任务并行库 (TPL)

转载 作者:行者123 更新时间:2023-11-30 20:11:29 31 4
gpt4 key购买 nike

我在阅读 Essential C# 4.0 时收到有关 ADI 的评论:

Unfortunately, the underlying technology used by the asynchronous delegate invocation pattern is an end-of-further-development technology for distributed programming known as remoting. And although Microsoft still supports the use of asynchronous delegate invocation and it will continue to function as it does today for the foreseeable future, the performance characteristics are suboptimal given other approaches—namely Thread, ThreadPool, and TPL. Therefore, developers should tend to favor one of these alternatives rather than implementing new development using the asynchronous delegate invocation API. Further discussion of the pattern is included in the Advanced Topic text that follows so that developers who encounter it will understand how it works.

除了 TPL 可能使用尚未结束的进一步开发技术之外,ADI 有什么限制而 TPL 没有?

最佳答案

任务和异步委托(delegate)都使用线程池。

任务和异步委托(delegate)在异常可以传播给调用者的意义上是相似的。任务更进一步,累积所有抛出的异常并将它们一起呈现给所有线程池 worker 。

任务允许取消。

有一个免费章节更详细地描述了所有这些: http://www.albahari.com/threading/

关于c# - 异步委托(delegate)调用 (ADI) 与任务并行库 (TPL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3740603/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com