.NET Framework Class Library |
TaskScheduler..::.GetScheduledTasks Method |
TaskScheduler Class See Also Send Feedback |
Namespace:
System.Threading.Tasks
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Protected MustOverride Function GetScheduledTasks As IEnumerable(Of Task) |
C# |
---|
protected abstract IEnumerable<Task> GetScheduledTasks() |
Return Value
An enumerable that allows traversal of tasks currently queued to this scheduler.Remarks
A class derived from 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.
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, the method should prefer to throw a NotSupportedException than to block, which could cause a debugger to experience delays. Additionally, this method and the enumerable returned must not modify any globally visible state.
The returned enumerable should never be null. If there are currently no queued tasks, an empty enumerable should be returned instead.
For developers implementing a custom debugger, this method shouldn't be called directly, but rather this functionality should be accessed through the internal wrapper method GetScheduledTasksForDebugger: internal Task[] GetScheduledTasksForDebugger(). This method returns an array of tasks, rather than an enumerable. In order to retrieve a list of active schedulers, a debugger may use another internal method: internal static TaskScheduler[] GetTaskSchedulersForDebugger(). This static method returns an array of all active TaskScheduler instances. GetScheduledTasksForDebugger then may be used on each of these scheduler instances to retrieve the list of scheduled tasks for each.
Exceptions
Exception | Condition |
---|---|
System..::.NotSupportedException | This scheduler is unable to generate a list of queued tasks at this time. |