Share via


TaskScheduler.FromCurrentSynchronizationContext Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Creates a TaskScheduler associated with the current System.Threading.SynchronizationContext.

Namespace:  System.Threading.Tasks
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Shared Function FromCurrentSynchronizationContext As TaskScheduler
public static TaskScheduler FromCurrentSynchronizationContext()

Return Value

Type: System.Threading.Tasks.TaskScheduler
A TaskScheduler associated with the current SynchronizationContex[t], as determined by SynchronizationContext.Current.

Exceptions

Exception Condition
InvalidOperationException

The current SynchronizationContext may not be used as a TaskScheduler.

Remarks

All Task instances queued to the returned scheduler will be executed through a call to the Post method on that context.

For more information, see Task Schedulers.

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.