在Asp.net Core中使用thread.Abort()的替代方法? [英] Alternative of thread.Abort() in Asp.net Core?
问题描述
asp.net核心中的thread.Abort()是否有其他选择,因为它不再支持.Core.
Is there any alternative option for thread.Abort() in asp.net core as it no longer support with .Core.
// Exceptions:
// T:System.PlatformNotSupportedException:
// .NET Core only: This member is not supported.
这是引发PlatformNotSupportedException异常.
This is throw PlatformNotSupportedException exception.
我使用了thread.Interrupt(),但它没有按预期工作.
I used thread.Interrupt() but it not work as per expectation.
推荐答案
Thread.Abort()
已被删除,因为它不能可靠地移植到所有平台,并且通常会对整个应用程序域(如果使用不当).
Thread.Abort()
has been removed, since it could not be reliably ported to all platforms and in general poses a threat to the entire app domain, when used incorrectly.
推荐的方法(尤其是对于ASP.NET Core)现在是使用任务,并使用取消令牌.您可以在此处了解更多有关如何使用CancellationTokens的信息..
The recommended way (especially for ASP.NET Core) is now to use Tasks and "abort" them with CancellationTokens. You can learn more about how to use CancellationTokens here.
这篇关于在Asp.net Core中使用thread.Abort()的替代方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!