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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
|
<?xml version="1.0" encoding="utf-8"?>
<Type Name="TaskScheduler" FullName="System.Threading.Tasks.TaskScheduler">
<TypeSignature Language="C#" Value="public abstract class TaskScheduler" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract beforefieldinit TaskScheduler extends System.Object" />
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName>System.Diagnostics.DebuggerDisplay("Id={Id}")</AttributeName>
</Attribute>
<Attribute>
<AttributeName>System.Diagnostics.DebuggerTypeProxy(typeof(System.Threading.Tasks.TaskScheduler/TaskSchedulerDebuggerView))</AttributeName>
</Attribute>
</Attributes>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>
<see cref="T:System.Threading.Tasks.TaskScheduler" /> acts as the extension point for all pluggable scheduling logic. This includes mechanisms such as how to schedule a task for execution, and how scheduled tasks should be exposed to debuggers. </para>
<para>For more information and code examples, see <format type="text/html"><a href="638f8ea5-21db-47a2-a934-86e1e961bf65">Task Schedulers</a></format>.</para>
<para>Several sample task schedulers are available on Code Gallery: <see cref="http://go.microsoft.com/fwlink/?LinkID=165717">Samples for Parallel Programming with the .NET Framework 4</see>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Represents an object that handles the low-level work of queuing tasks onto threads.</para>
</summary>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="protected TaskScheduler ();" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<remarks>To be added.</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Initializes the <see cref="T:System.Threading.Tasks.TaskScheduler" />.</para>
</summary>
</Docs>
</Member>
<Member MemberName="Current">
<MemberSignature Language="C#" Value="public static System.Threading.Tasks.TaskScheduler Current { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Threading.Tasks.TaskScheduler Current" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.TaskScheduler</ReturnType>
</ReturnValue>
<Docs>
<value>To be added.</value>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>When not called from within a task, <see cref="P:System.Threading.Tasks.TaskScheduler.Current" /> will return the <see cref="P:System.Threading.Tasks.TaskScheduler.Default" /> scheduler.</para>
<para>For more information, see <format type="text/html"><a href="638f8ea5-21db-47a2-a934-86e1e961bf65">Task Schedulers</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Gets the <see cref="T:System.Threading.Tasks.TaskScheduler" /> associated with the currently executing task.</para>
</summary>
</Docs>
</Member>
<Member MemberName="Default">
<MemberSignature Language="C#" Value="public static System.Threading.Tasks.TaskScheduler Default { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Threading.Tasks.TaskScheduler Default" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.TaskScheduler</ReturnType>
</ReturnValue>
<Docs>
<value>To be added.</value>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>For more information, see <format type="text/html"><a href="638f8ea5-21db-47a2-a934-86e1e961bf65">Task Schedulers</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Gets the default <see cref="T:System.Threading.Tasks.TaskScheduler" /> instance that is provided by the .NET Framework.</para>
</summary>
</Docs>
</Member>
<Member MemberName="FromCurrentSynchronizationContext">
<MemberSignature Language="C#" Value="public static System.Threading.Tasks.TaskScheduler FromCurrentSynchronizationContext ();" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Threading.Tasks.TaskScheduler FromCurrentSynchronizationContext() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Threading.Tasks.TaskScheduler</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>All <see cref="T:System.Threading.Tasks.Task" /> instances queued to the returned scheduler will be executed through a call to the <see cref="M:System.Threading.SynchronizationContext.Post(System.Threading.SendOrPostCallback,System.Object)" /> method on that context.</para>
<para>For more information, see <format type="text/html"><a href="638f8ea5-21db-47a2-a934-86e1e961bf65">Task Schedulers</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Creates a <see cref="T:System.Threading.Tasks.TaskScheduler" /> associated with the current <see cref="T:System.Threading.SynchronizationContext" />.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>A <see cref="T:System.Threading.Tasks.TaskScheduler" /> associated with the current <see cref="T:System.Threading.SynchronizationContext" />, as determined by <see cref="P:System.Threading.SynchronizationContext.Current" />.</para>
</returns>
</Docs>
</Member>
<Member MemberName="GetScheduledTasks">
<MemberSignature Language="C#" Value="protected abstract System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task> GetScheduledTasks ();" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance class System.Collections.Generic.IEnumerable`1<class System.Threading.Tasks.Task> GetScheduledTasks() cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task></ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>A class derived from <see cref="T:System.Threading.Tasks.TaskScheduler" /> implements this method in order to support integration with debuggers. This method will only be invoked by the .NET Framework when the debugger requests access to the data. The enumerable returned will be traversed by debugging utilities to access the tasks currently queued to this scheduler, enabling the debugger to provide a representation of this information in the user interface.</para>
<para>It is important to note that, when this method is called, all other threads in the process will be frozen. Therefore, it's important to avoid synchronization with other threads that may lead to blocking. If synchronization is necessary, and you are unable to acquire the lock in this method, then you should throw an exception so that the debugger does not hang. The following example shows one possible approach in C#:</para>
<code>protected override IEnumerable<Task> GetScheduledTasks()
{
bool lockTaken = false;
try
{
Monitor.TryEnter(_syncObj, ref lockTaken);
if (lockTaken)
{
return _tasks.ToArray();
}
else throw new NotSupportedException();
}
finally
{
if (lockTaken) Monitor.Exit(_syncObj);
}}</code>
<para>Additionally, this method and the enumerable returned must not modify any globally visible state.</para>
<para>The returned enumerable should never be null. If there are currently no queued tasks, an empty enumerable should be returned instead.</para>
<para>Developers who are implementing custom debuggers shouldn't call this method directly, but should use the internal wrapper method GetScheduledTasksForDebugger instead: internal Task[] GetScheduledTasksForDebugger(). This wrapper method returns an array of tasks instead of an enumerable. To retrieve a list of active schedulers, use the internal method internal static TaskScheduler[] GetTaskSchedulersForDebugger(). This static method returns an array of all active <see cref="T:System.Threading.Tasks.TaskScheduler" /> instances. You can then use GetScheduledTasksForDebugger on each scheduler instance to retrieve its list of scheduled tasks. </para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>For debugger support only, generates an enumerable of <see cref="T:System.Threading.Tasks.Task" /> instances currently queued to the scheduler waiting to be executed.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>An enumerable that allows a debugger to traverse the tasks currently queued to this scheduler.</para>
</returns>
</Docs>
</Member>
<Member MemberName="Id">
<MemberSignature Language="C#" Value="public int Id { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 Id" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<value>To be added.</value>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>For more information, see <format type="text/html"><a href="638f8ea5-21db-47a2-a934-86e1e961bf65">Task Schedulers</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Gets the unique ID for this <see cref="T:System.Threading.Tasks.TaskScheduler" />.</para>
</summary>
</Docs>
</Member>
<Member MemberName="MaximumConcurrencyLevel">
<MemberSignature Language="C#" Value="public virtual int MaximumConcurrencyLevel { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 MaximumConcurrencyLevel" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<value>To be added.</value>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>For more information, see <format type="text/html"><a href="638f8ea5-21db-47a2-a934-86e1e961bf65">Task Schedulers</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Indicates the maximum concurrency level this <see cref="T:System.Threading.Tasks.TaskScheduler" /> is able to support.</para>
</summary>
</Docs>
</Member>
<Member MemberName="QueueTask">
<MemberSignature Language="C#" Value="protected abstract void QueueTask (System.Threading.Tasks.Task task);" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig newslot virtual instance void QueueTask(class System.Threading.Tasks.Task task) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="task" Type="System.Threading.Tasks.Task" />
</Parameters>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para> A class derived from <see cref="T:System.Threading.Tasks.TaskScheduler" /> implements this method to accept tasks being scheduled on the scheduler.</para>
<para> A typical implementation would store the task in an internal data structure, which would be serviced by threads that would execute those tasks at some time in the future.</para>
<para> This method is only meant to be called by the .NET Framework and should not be called directly by the derived class. This is necessary for maintaining the consistency of the system.</para>
<para> </para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Queues a <see cref="T:System.Threading.Tasks.Task" /> to the scheduler. </para>
</summary>
<param name="task">
<attribution license="cc4" from="Microsoft" modified="false" />The <see cref="T:System.Threading.Tasks.Task" /> to be queued.</param>
</Docs>
</Member>
<Member MemberName="TryDequeue">
<MemberSignature Language="C#" Value="protected virtual bool TryDequeue (System.Threading.Tasks.Task task);" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig newslot virtual instance bool TryDequeue(class System.Threading.Tasks.Task task) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="task" Type="System.Threading.Tasks.Task" />
</Parameters>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>For more information, see <format type="text/html"><a href="638f8ea5-21db-47a2-a934-86e1e961bf65">Task Schedulers</a></format>.</para>
<para>This method may execute in a finally block; therefore it should return as quickly as possible so that any resources such as <see cref="T:System.Threading.CancellationTokenRegistration" /> objects can be disposed of in a timely manner.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Attempts to dequeue a <see cref="T:System.Threading.Tasks.Task" /> that was previously queued to this scheduler.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>A Boolean denoting whether the <paramref name="task" /> argument was successfully dequeued.</para>
</returns>
<param name="task">
<attribution license="cc4" from="Microsoft" modified="false" />The <see cref="T:System.Threading.Tasks.Task" /> to be dequeued.</param>
</Docs>
</Member>
<Member MemberName="TryExecuteTask">
<MemberSignature Language="C#" Value="protected bool TryExecuteTask (System.Threading.Tasks.Task task);" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig instance bool TryExecuteTask(class System.Threading.Tasks.Task task) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="task" Type="System.Threading.Tasks.Task" />
</Parameters>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para> Scheduler implementations are provided with <see cref="T:System.Threading.Tasks.Task" /> instances to be executed through either the <see cref="M:System.Threading.Tasks.TaskScheduler.QueueTask(System.Threading.Tasks.Task)" /> method or the <see cref="M:System.Threading.Tasks.TaskScheduler.TryExecuteTaskInline(System.Threading.Tasks.Task,System.Boolean)" /> method. When the scheduler deems it appropriate to run the provided task, <see cref="M:System.Threading.Tasks.TaskScheduler.TryExecuteTask(System.Threading.Tasks.Task)" /> should be used to do so. TryExecuteTask handles all aspects of executing a task, including action invocation, exception handling, state management, and lifecycle control.</para>
<para> <see cref="M:System.Threading.Tasks.TaskScheduler.TryExecuteTask(System.Threading.Tasks.Task)" /> must only be used for tasks provided to this scheduler by the .NET Framework infrastructure. It should not be used to execute arbitrary tasks obtained through custom mechanisms.</para>
<para> </para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Attempts to execute the provided <see cref="T:System.Threading.Tasks.Task" /> on this scheduler.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>A Boolean that is true if <paramref name="task" /> was successfully executed, false if it was not. A common reason for execution failure is that the task had previously been executed or is in the process of being executed by another thread.</para>
</returns>
<param name="task">
<attribution license="cc4" from="Microsoft" modified="false" />A <see cref="T:System.Threading.Tasks.Task" /> object to be executed.</param>
</Docs>
</Member>
<Member MemberName="TryExecuteTaskInline">
<MemberSignature Language="C#" Value="protected abstract bool TryExecuteTaskInline (System.Threading.Tasks.Task task, bool taskWasPreviouslyQueued);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance bool TryExecuteTaskInline(class System.Threading.Tasks.Task task, bool taskWasPreviouslyQueued) cil managed" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="task" Type="System.Threading.Tasks.Task" />
<Parameter Name="taskWasPreviouslyQueued" Type="System.Boolean" />
</Parameters>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>A class derived from <see cref="T:System.Threading.Tasks.TaskScheduler" /> implements this function to support inline execution of a task on a thread that initiates a wait on that task object. Inline execution is optional, and the request may be rejected by returning false. However, the more tasks that can be inlined, the better the scheduler will scale. In fact, a scheduler that inlines too little may be prone to deadlocks. A proper implementation should ensure that a request executing under the policies guaranteed by the scheduler can successfully inline. For example, if a scheduler uses a dedicated thread to execute tasks, any inlining requests from that thread should succeed.</para>
<para>If a scheduler decides to perform the inline execution, it should do so by calling to the base TaskScheduler's <see cref="M:System.Threading.Tasks.TaskScheduler.TryExecuteTask(System.Threading.Tasks.Task)" /> method with the provided task object, propagating the return value. It may also be appropriate for the scheduler to remove an inlined task from its internal data structures if it decides to honor the inlining request. Note, however, that under some circumstances a scheduler may be asked to inline a task that was not previously provided to it with the <see cref="M:System.Threading.Tasks.TaskScheduler.QueueTask(System.Threading.Tasks.Task)" /> method.</para>
<para>The derived scheduler is responsible for making sure that the calling thread is suitable for executing the given task as far as its own scheduling and execution policies are concerned.</para>
<para>For more information, see <format type="text/html"><a href="638f8ea5-21db-47a2-a934-86e1e961bf65">Task Schedulers</a></format>.</para>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Determines whether the provided <see cref="T:System.Threading.Tasks.Task" /> can be executed synchronously in this call, and if it can, executes it.</para>
</summary>
<returns>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>A Boolean value indicating whether the task was executed inline.</para>
</returns>
<param name="task">
<attribution license="cc4" from="Microsoft" modified="false" />The <see cref="T:System.Threading.Tasks.Task" /> to be executed.</param>
<param name="taskWasPreviouslyQueued">
<attribution license="cc4" from="Microsoft" modified="false" />A Boolean denoting whether or not task has previously been queued. If this parameter is True, then the task may have been previously queued (scheduled); if False, then the task is known not to have been queued, and this call is being made in order to execute the task inline without queuing it.</param>
</Docs>
</Member>
<Member MemberName="UnobservedTaskException">
<MemberSignature Language="C#" Value="public static event EventHandler<System.Threading.Tasks.UnobservedTaskExceptionEventArgs> UnobservedTaskException;" />
<MemberSignature Language="ILAsm" Value=".event class System.EventHandler`1<class System.Threading.Tasks.UnobservedTaskExceptionEventArgs> UnobservedTaskException" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.EventHandler<System.Threading.Tasks.UnobservedTaskExceptionEventArgs></ReturnType>
</ReturnValue>
<Docs>
<remarks>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>This application domain-wide event provides a mechanism to prevent exception escalation policy (which, by default, terminates the process) from triggering. </para>
<para>To make it easier for developers to write asynchronous code based on tasks, the net_v45 changes the default exception behavior for unobserved exceptions. Although unobserved exceptions still raise the <see cref="E:System.Threading.Tasks.TaskScheduler.UnobservedTaskException" /> exception, the process does not terminate by default. Instead, the exception is handled by the runtime after the event is raised, regardless of whether an event handler observes the exception. This behavior can be configured. Starting with the net_v45, you can use the <format type="text/html"><a href="cea7e588-8b8d-48d2-9ad5-8feaf3642c18"><ThrowUnobservedTaskExceptions></a></format> configuration element to revert to the behavior of the net_v40_long and terminate the process:</para>
<code><configuration>
<runtime>
<ThrowUnobservedTaskExceptions enabled="true"/>
</runtime>
</configuration>
</code>
</remarks>
<summary>
<attribution license="cc4" from="Microsoft" modified="false" />
<para>Occurs when a faulted task's unobserved exception is about to trigger exception escalation policy, which, by default, would terminate the process.</para>
</summary>
</Docs>
</Member>
</Members>
</Type>
|