mscorlib(4.0.0.0) API with additions
ConfiguredTaskAwaitable.cs
1 using System.Security;
4 
6 {
8  [__DynamicallyInvokable]
9  public struct ConfiguredTaskAwaitable
10  {
12  [__DynamicallyInvokable]
13  [HostProtection(SecurityAction.LinkDemand, Synchronization = true, ExternalThreading = true)]
15  {
16  private readonly Task m_task;
17 
18  private readonly bool m_continueOnCapturedContext;
19 
24  [__DynamicallyInvokable]
25  public bool IsCompleted
26  {
27  [__DynamicallyInvokable]
28  get
29  {
30  return m_task.IsCompleted;
31  }
32  }
33 
34  internal ConfiguredTaskAwaiter(Task task, bool continueOnCapturedContext)
35  {
36  m_task = task;
37  m_continueOnCapturedContext = continueOnCapturedContext;
38  }
39 
44  [SecuritySafeCritical]
45  [__DynamicallyInvokable]
46  public void OnCompleted(Action continuation)
47  {
48  TaskAwaiter.OnCompletedInternal(m_task, continuation, m_continueOnCapturedContext, flowExecutionContext: true);
49  }
50 
55  [SecurityCritical]
56  [__DynamicallyInvokable]
57  public void UnsafeOnCompleted(Action continuation)
58  {
59  TaskAwaiter.OnCompletedInternal(m_task, continuation, m_continueOnCapturedContext, flowExecutionContext: false);
60  }
61 
66  [__DynamicallyInvokable]
67  public void GetResult()
68  {
69  TaskAwaiter.ValidateEnd(m_task);
70  }
71  }
72 
73  private readonly ConfiguredTaskAwaiter m_configuredTaskAwaiter;
74 
75  internal ConfiguredTaskAwaitable(Task task, bool continueOnCapturedContext)
76  {
77  m_configuredTaskAwaiter = new ConfiguredTaskAwaiter(task, continueOnCapturedContext);
78  }
79 
82  [__DynamicallyInvokable]
84  {
85  return m_configuredTaskAwaiter;
86  }
87  }
90  [__DynamicallyInvokable]
91  public struct ConfiguredTaskAwaitable<TResult>
92  {
94  [__DynamicallyInvokable]
95  [HostProtection(SecurityAction.LinkDemand, Synchronization = true, ExternalThreading = true)]
97  {
98  private readonly Task<TResult> m_task;
99 
100  private readonly bool m_continueOnCapturedContext;
101 
106  [__DynamicallyInvokable]
107  public bool IsCompleted
108  {
109  [__DynamicallyInvokable]
110  get
111  {
112  return m_task.IsCompleted;
113  }
114  }
115 
116  internal ConfiguredTaskAwaiter(Task<TResult> task, bool continueOnCapturedContext)
117  {
118  m_task = task;
119  m_continueOnCapturedContext = continueOnCapturedContext;
120  }
121 
126  [SecuritySafeCritical]
127  [__DynamicallyInvokable]
128  public void OnCompleted(Action continuation)
129  {
130  TaskAwaiter.OnCompletedInternal(m_task, continuation, m_continueOnCapturedContext, flowExecutionContext: true);
131  }
132 
137  [SecurityCritical]
138  [__DynamicallyInvokable]
139  public void UnsafeOnCompleted(Action continuation)
140  {
141  TaskAwaiter.OnCompletedInternal(m_task, continuation, m_continueOnCapturedContext, flowExecutionContext: false);
142  }
143 
149  [__DynamicallyInvokable]
150  public TResult GetResult()
151  {
152  TaskAwaiter.ValidateEnd(m_task);
153  return m_task.ResultOnSuccess;
154  }
155  }
156 
157  private readonly ConfiguredTaskAwaiter m_configuredTaskAwaiter;
158 
159  internal ConfiguredTaskAwaitable(Task<TResult> task, bool continueOnCapturedContext)
160  {
161  m_configuredTaskAwaiter = new ConfiguredTaskAwaiter(task, continueOnCapturedContext);
162  }
163 
166  [__DynamicallyInvokable]
168  {
169  return m_configuredTaskAwaiter;
170  }
171  }
172 }
Represents an operation that schedules continuations when it completes.
Definition: __Canon.cs:3
void OnCompleted(Action continuation)
Schedules the continuation action for the task associated with this awaiter.
delegate void Action()
Encapsulates a method that has no parameters and does not return a value.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides an object that waits for the completion of an asynchronous task.
Definition: TaskAwaiter.cs:14
ConfiguredTaskAwaiter GetAwaiter()
Returns an awaiter for this awaitable object.
Provides an awaitable object that enables configured awaits on a task.
Creates or manipulates threads other than its own, which might be harmful to the host.
void UnsafeOnCompleted(Action continuation)
Schedules the continuation action for the task associated with this awaiter.
Provides an awaiter for an awaitable (T:System.Runtime.CompilerServices.ConfiguredTaskAwaitable) obje...
Represents an awaiter that schedules continuations when an await operation completes.
Represents an asynchronous operation that can return a value.
Definition: Task.cs:18
bool IsCompleted
Gets a value that specifies whether the task being awaited is completed.