为什么ContinueWhenAll 和ContinueWhenAny 具有不受支持的TaskContinuationOptions?

发布于 2025-01-02 20:35:20 字数 302 浏览 3 评论 0原文

当我浏览 MSDN 和其他书籍上的文档时,我发现这两个函数都有一个接受 TaskContinuationOption 的重载。但他们可以根据这个声明抛出异常:

排除多个任务的延续的特定延续类型是无效的。

看起来它们只允许 TaskContinuationOptions.AttachedToParent、LongRunning、PreferFairness、ExecuteSynchronously 和 None,类似于 TaskCreationOption 枚举。

为什么会这样呢?

When I go through documentation on MSDN and other books, I've seen that both functions have an overload that accepts a TaskContinuationOption. But they can throw an exception according to this statement:

It is invalid to exclude specific continuation kinds for continuations off of multiple tasks.

It seems that they only allow TaskContinuationOptions.AttachedToParent, LongRunning, PreferFairness, ExecuteSynchronously and None, similar to the TaskCreationOption enum.

Why is this so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初心 2025-01-09 20:35:20

那么,无效的 NotOn* 和 OnlyOn* TaskContinueOption 值描述了单个任务的继续选项。这是不行的,ContinueWhenAll() 和ContinueWhenAny() 方法适用于一组任务。检查选项并抛出 ArgumentOutOfRange 异常的内部方法名为“CheckMultiTaskContinuationOptions”,强调MultiTask

Well, the invalid NotOn* and OnlyOn* TaskContinueOption values describe a continue option for a single task. Which won't do, the ContinueWhenAll() and ContinueWhenAny() methods work with a set of tasks. The internal method that checks the options and throws the ArgumentOutOfRange exception is named "CheckMultiTaskContinuationOptions", emphasis on MultiTask.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文