CancellationTokens 可以跨 AppDomains 使用吗

发布于 2024-08-30 16:01:33 字数 351 浏览 2 评论 0原文

.NET 4 引入了一些类型来很好地支持协作取消。我希望能够取消在不同 AppDomain 中运行的操作。 CancellationToken 类型是一个结构体。如果我将它传递给另一个AppDomain,它会正常工作吗?

.NET 4 introduced some types to nicely support cooperative cancellation. I would like to be able to cancel an operation which is running in a different AppDomain. The CancellationToken type is a struct. If I pass it to another AppDomain, will it work as normal?

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

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

发布评论

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

评论(1

夏日浅笑〃 2024-09-06 16:01:33

我不熟悉 .NET 4 或取消令牌,但取消结构似乎没有 SerializedAttribute,因此您可能无法首先跨 AppDomain 边界获取它。

不过,您也许可以创建一个 MarshalByRefObject 包装器来为您执行此操作。

I'm not familiar with .NET 4 or cancellation tokens, but the cancellation struct doesn't appear to have the SerializableAttribute so you probably won't be able to get it across the AppDomain boundry in the first place.

You might be able to create a MarshalByRefObject wrapper to do this for you though.

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