File: ThreadAbortException.xml

package info (click to toggle)
mono 6.8.0.105%2Bdfsg-3.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,284,512 kB
  • sloc: cs: 11,172,132; xml: 2,850,069; ansic: 671,653; cpp: 122,091; perl: 59,366; javascript: 30,841; asm: 22,168; makefile: 20,093; sh: 15,020; python: 4,827; pascal: 925; sql: 859; sed: 16; php: 1
file content (123 lines) | stat: -rw-r--r-- 6,735 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?xml version="1.0" encoding="utf-8"?>
<Type Name="ThreadAbortException" FullName="System.Threading.ThreadAbortException" FullNameSP="System_Threading_ThreadAbortException" Maintainer="ecma">
  <TypeSignature Language="ILASM" Value=".class public sealed serializable ThreadAbortException extends System.SystemException" />
  <TypeSignature Language="C#" Value="public sealed class ThreadAbortException : SystemException" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi serializable sealed beforefieldinit ThreadAbortException extends System.SystemException" />
  <MemberOfLibrary>BCL</MemberOfLibrary>
  <AssemblyInfo>
    <AssemblyName>mscorlib</AssemblyName>
    <AssemblyPublicKey>[00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ]</AssemblyPublicKey>
    <AssemblyVersion>1.0.5000.0</AssemblyVersion>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
    <AssemblyVersion>4.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <ThreadingSafetyStatement>All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.</ThreadingSafetyStatement>
  <Base>
    <BaseTypeName>System.SystemException</BaseTypeName>
  </Base>
  <Interfaces />
  <Attributes>
    <Attribute>
      <AttributeName>System.Runtime.InteropServices.ComVisible(true)</AttributeName>
    </Attribute>
  </Attributes>
  <Docs>
    <example>
      <para>The following example demonstrates aborting a thread.
      The thread that receives the <see cref="T:System.Threading.ThreadAbortException" /> uses the <see cref="M:System.Threading.Thread.ResetAbort" /> method to cancel the abort request and
      continue executing.</para>
      <code lang="C#">using System;
using System.Threading;
using System.Security.Permissions;

public class ThreadWork {
  public static void DoWork() {
    try {
      for (int i=0; i&lt;100; i++) {
        Console.WriteLine("Thread - working."); 
        Thread.Sleep(100);
      }
    }
    catch (ThreadAbortException e) {
      Console.WriteLine("Thread - caught ThreadAbortException - resetting.");
      Thread.ResetAbort();
    }
    Console.WriteLine("Thread - still alive and working."); 
    Thread.Sleep(1000);
    Console.WriteLine("Thread - finished working.");
  } 
}

class ThreadAbortTest{
  public static void Main() {
    ThreadStart myThreadDelegate = new ThreadStart(ThreadWork.DoWork);
    Thread myThread = new Thread(myThreadDelegate);
    myThread.Start();
    Thread.Sleep(100);
    Console.WriteLine("Main - aborting my thread.");
    myThread.Abort();
    myThread.Join();
    Console.WriteLine("Main ending."); 
  }
}
   </code>
      <para>The output is </para>
      <c>
        <para>Thread - working.</para>
        <para>Main - aborting my thread.</para>
        <para>Thread - caught ThreadAbortException - resetting.</para>
        <para>Thread - still alive and working.</para>
        <para>Thread - finished working.</para>
        <para>Main ending.</para>
      </c>
    </example>
    <remarks>
      <attribution license="cc4" from="Microsoft" modified="false" />
      <para>When a call is made to the <see cref="M:System.Threading.Thread.Abort(System.Object)" /> method to destroy a thread, the common language runtime throws a <see cref="T:System.Threading.ThreadAbortException" />. <see cref="T:System.Threading.ThreadAbortException" /> is a special exception that can be caught, but it will automatically be raised again at the end of the catch block. When this exception is raised, the runtime executes all the finally blocks before ending the thread. Because the thread can do an unbounded computation in the finally blocks or call <see cref="M:System.Threading.Thread.ResetAbort" /> to cancel the abort, there is no guarantee that the thread will ever end. If you want to wait until the aborted thread has ended, you can call the <see cref="M:System.Threading.Thread.Join" /> method. <see cref="M:System.Threading.Thread.Join" /> is a blocking call that does not return until the thread actually stops executing.</para>
      <block subset="none" type="note">
        <para>When the common language runtime (CLR) stops background threads after all foreground threads in a managed executable have ended, it does not use <see cref="Overload:System.Threading.Thread.Abort" />. Therefore, you cannot use <see cref="T:System.Threading.ThreadAbortException" /> to detect when background threads are being terminated by the CLR.</para>
      </block>
      <para>
        <see cref="T:System.Threading.ThreadAbortException" /> uses the HRESULT COR_E_THREADABORTED, which has the value 0x80131530.</para>
      <block subset="none" type="note">
        <para>The value of the inherited <see cref="P:System.Exception.Data" /> property is always null.</para>
      </block>
    </remarks>
    <summary>
      <attribution license="cc4" from="Microsoft" modified="false" />
      <para>The exception that is thrown when a call is made to the <see cref="M:System.Threading.Thread.Abort(System.Object)" /> method. This class cannot be inherited.</para>
    </summary>
  </Docs>
  <Members>
    <Member MemberName="ExceptionState">
      <MemberSignature Language="ILASM" Value=".property object ExceptionState { public hidebysig specialname instance object get_ExceptionState() }" />
      <MemberSignature Language="C#" Value="public object ExceptionState { get; }" />
      <MemberSignature Language="ILAsm" Value=".property instance object ExceptionState" />
      <MemberType>Property</MemberType>
      <AssemblyInfo>
        <AssemblyVersion>1.0.5000.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
        <AssemblyVersion>4.0.0.0</AssemblyVersion>
      </AssemblyInfo>
      <ReturnValue>
        <ReturnType>System.Object</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <value>
          <para>A <see cref="T:System.Object" />.</para>
        </value>
        <remarks>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>The object returned by this property is specified through the <paramref name="stateInfo" /> parameter of the <see cref="M:System.Threading.Thread.Abort(System.Object)" /> method. The exact content and usage of this object is application defined; it is typically used to convey information that is meaningful to the thread being aborted.</para>
        </remarks>
        <summary>
          <attribution license="cc4" from="Microsoft" modified="false" />
          <para>Gets an object that contains application-specific information related to the thread abort.</para>
        </summary>
      </Docs>
      <Excluded>0</Excluded>
    </Member>
  </Members>
  <TypeExcluded>0</TypeExcluded>
</Type>