The Labs \ Source Viewer \ SSCLI \ System.Threading \ ThreadAbortException

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*=============================================================================
  16. **
  17. ** Class: ThreadAbortException
  18. **
  19. **
  20. ** Purpose: An exception class which is thrown into a thread to cause it to
  21. **          abort. This is a special non-catchable exception and results in
  22. ** the thread's death.  This is thrown by the VM only and can NOT be
  23. **          thrown by any user thread, and subclassing this is useless.
  24. **
  25. **
  26. =============================================================================*/
  27. namespace System.Threading
  28. {
  29.     using System;
  30.     using System.Runtime.Serialization;
  31.     using System.Runtime.CompilerServices;
  32.    
  33.     [System.Runtime.InteropServices.ComVisible(true)]
  34.     [Serializable()]
  35.     public sealed class ThreadAbortException : SystemException
  36.     {
  37.         private ThreadAbortException() : base(GetMessageFromNativeResources(ExceptionMessageKind.ThreadAbort))
  38.         {
  39.             SetErrorCode(__HResults.COR_E_THREADABORTED);
  40.         }
  41.        
  42.         //required for serialization
  43.         internal ThreadAbortException(SerializationInfo info, StreamingContext context) : base(info, context)
  44.         {
  45.         }
  46.        
  47.         public object ExceptionState {
  48.             get { return Thread.CurrentThread.AbortReason; }
  49.         }
  50.     }
  51. }

Developer Fusion