locked
ThreadAbortException re-throw again RRS feed

  • Question

  • Need help from anyone who familiar with C#!
    The thing is I know that when I use Thread.Abort(); , the system will throw an ThreadAbortException. So I use try catch statement to catch it further then reset it.
    But the chance is 1 in 10 the system will rethrow Exception again, so what do I need to do? And any recommendation?
    Monday, September 10, 2018 4:48 PM

Answers

  • Hi Raymond MLD,

    Please check the thread in StackOverFlow. It gives a good suggestion.

    https://stackoverflow.com/questions/1856286/threadabortexception

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Thursday, September 27, 2018 6:16 AM
    • Marked as answer by Raymond MLD Wednesday, October 10, 2018 9:27 AM
    Thursday, September 20, 2018 1:32 AM

All replies

  • Hi Raymond MLD,

    Thank you for posting here.

    >>But the chance is 1 in 10 the system will rethrow Exception again,

    According to your description, where do you get the exception? In your code, you use Thread.Abort(), it will thrown the exception as well. Try to use the Try catch to call resetAbort.

    https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread.abort?redirectedfrom=MSDN&view=netframework-4.7.2#System_Threading_Thread_Abort

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 11, 2018 8:38 AM
  • Hello, the system throw an exception in try statement but I caught it and use resetAbort();.

    But the chance is sometimes it will re-throw again.

    What can I do?

    Tuesday, September 11, 2018 9:27 AM
  • Hi Raymond MLD,

    Please check the thread in StackOverFlow. It gives a good suggestion.

    https://stackoverflow.com/questions/1856286/threadabortexception

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Stanly Fan Thursday, September 27, 2018 6:16 AM
    • Marked as answer by Raymond MLD Wednesday, October 10, 2018 9:27 AM
    Thursday, September 20, 2018 1:32 AM