Skip to content

Request Thread.Abort to be marked [Obsolete] #28664

Closed

Description

@lcsondes

We're in the middle of porting a legacy Framework project to Core, and Thread.Abort() was a sore point. It compiles without a single warning, and at runtime it just throws a PNSE. Given the legacy status of our code cleanups tend to be wrapped in catch(Exception) so this went unnoticed until we saw the memory leaks and traced them back. That one is entirely on us, of course.

If Abort doesn't work and it is planned that it never will (which is my understanding) then I think it at the very least should be marked as [Obsolete], maybe even with IsError=true.

Activity

  1. benaadams commented on Feb 11, 2019

    @benaadams
    Member
  2. kouvel commented on Feb 23, 2019

    @kouvel
    Contributor

    These APIs are part of netstandard, so perhaps the warning should only occur when compiling for netcoreapp and not for netstandard, such that when compiling for runtimes that may support it would not warn. Not sure how exactly that would work but it may be possible.

  3. kouvel commented on Feb 23, 2019

    @kouvel
    Contributor

    Would be nice to have some kind of tool anyway that would give compat warnings if not the compiler.

  4. Symbai commented on Nov 18, 2019

    @Symbai

    This should definitely throw an error. It is not even documented in the breaking change docs: https://docs.microsoft.com/en-us/dotnet/core/compatibility/framework-core

    What's the equivalent on .NET Core?

  5. kouvel commented on Nov 18, 2019

    @kouvel
    Contributor

    What's the equivalent on .NET Core?

    There's no reasonable equivalent in .NET Core and it's not planned to be supported there. https://github.com/dotnet/coreclr/issues/20705#issuecomment-443433749 and other comments in that issue describe the reasons for it.

    This should definitely throw an error.

    Since this is a runtime-specific difference, when compiling for netstandard perhaps it could be a compat warning since they may run on runtimes that allow thread abort. When compiling for netcoreapp it probably should be an error. I don't think there's a way to do that currently.

    For now the .NET API Analyzer might be useful: https://docs.microsoft.com/en-us/dotnet/core/porting/

  6. danmoseley commented on Nov 19, 2019

    @danmoseley
    Contributor
  7. PhilipHassialis commented on Dec 31, 2019

    @PhilipHassialis

    Is there any recent development on this? Thread.Abort() can still be typed without any kind of intellisense from the editor that it is obsolete (.NET Core 3.1 here). Souldn't the Abort becoming obsolete and/or moving out of .Net Core be mentioned in the documentation?

  8. jkotas commented on Jan 1, 2020

    @jkotas
    Member

    mentioned in the documentation

    It is mentioned in the documentation. Look for ".NET Core only: This member is not supported." in https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread.abort?view=netcore-3.1

    obsolete

    @terrajobst is working on a plan for obsoleting APIs like this.

  9. PhilipHassialis commented on Jan 1, 2020

    @PhilipHassialis

    Ah thanks a bunch - unfortunately didn't catch this one, saw the method there along with the example and didn't catch this one. A million apologies beforehand, unfortunately most of the C# courses out there keep mentioning the method, oblivious to the changes that Core brings to the APIs. As an adage, could the documentation team kindly put something in the titles or the first paragraph or somesuch of the APIs to be deprecated so that users can immediately see that these methods may be there but will not work?

    Thanks so much in advance, happy new year and once again apologies for my quite rushed questioning.

  10. transferred this issue fromdotnet/corefxon Feb 1, 2020
  11. added this to the 5.0 milestone on Feb 1, 2020
  12. added
    untriaged
    on Feb 23, 2020
  13. stephentoub commented on Feb 25, 2020

    @stephentoub
    Member

    @terrajobst, how should issues like this feed into your obsoletion/tooling plans?

  14. removed
    untriaged
    on Feb 25, 2020
  15. modified the milestones: 5.0.0, 6.0.0 on Jul 22, 2020
  16. terrajobst commented on Jan 8, 2021

    @terrajobst
    Contributor

    This has been done for .NET 5 so this can be closed. Thanks @jeffhandley for pointing this out to me!

  17. ghost locked as resolved and limited conversation to collaborators on Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions