为什么ContinueWhenAll 和ContinueWhenAny 具有不受支持的TaskContinuationOptions?
当我浏览 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么,无效的 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.