Abort is not supported on this platform. Need guidence. How to solve this issue? i am working on splash screen.

sherry leo 1 Reputation point
2022-01-14T00:15:03.773+00:00

165001-hel.jpg

Developer technologies | C#
{count} votes

3 answers

Sort by: Most helpful
  1. P a u l 10,761 Reputation points
    2022-01-14T00:45:38.49+00:00

    The cleanest way to stop a thread is by stopping them cooperatively, i.e. you pass an object to your thread to communicate that you want it to terminate. You can create one CancellationToken and pass it to any third-party calls you're executing in your thread:
    https://learn.microsoft.com/en-us/dotnet/standard/threading/using-threads-and-threading#how-to-stop-a-thread
    https://learn.microsoft.com/en-us/dotnet/standard/threading/cancellation-in-managed-threads#code-example

    Since .NET 5 the Thread.Abort method throws this exception, so either the thread needs to be cancelled or it needs to be ran as part of a separate process. If you use a separate process you can call Process.Kill to force it to terminate, although that may not be ideal depending on your application.

    0 comments No comments

  2. Jack J Jun 25,296 Reputation points
    2022-01-14T06:14:18.897+00:00

    @sherry leo , as the Microsoft article said, Thread.Abort is obsolete.

    Previously, calls to Thread.Abort did not produce compile-time warnings, however, the method did throw a PlatformNotSupportedException at run time.

    You can refer to the following link to use CancellationToken and suppress the compile-time warning to try to solve your problem.

    Recommended action


    If the response is helpful, please click "Accept Answer" and upvote it.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. sherry leo 1 Reputation point
    2022-01-14T11:56:23.947+00:00

    165076-hel.jpg

    I am working like this i have tried join and timer but it didn't work and i have tried cancelation token too but cancelation token is not accepting splash screen. Any other alternative to start a form until the second form loads and then close it in .net5?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.