Struct TaskSchedulerAwaiter
An awaiter returned from GetAwaiter().
Inherited Members
Namespace: DevToys.Api
Assembly: DevToys.Api.dll
Syntax
public readonly struct TaskSchedulerAwaiter : ICriticalNotifyCompletion, INotifyCompletion
Constructors
TaskSchedulerAwaiter(TaskScheduler, CancellationToken, bool)
Initializes a new instance of the TaskSchedulerAwaiter struct.
Declaration
public TaskSchedulerAwaiter(TaskScheduler scheduler, CancellationToken cancellationToken, bool alwaysYield = false)
Parameters
Type | Name | Description |
---|---|---|
TaskScheduler | scheduler | The scheduler for continuations. |
CancellationToken | cancellationToken | A CancellationToken to observe while waiting for the task to complete. |
bool | alwaysYield | A value indicating whether the caller should yield even if already executing on the desired task scheduler. |
Properties
IsCompleted
Gets a value indicating whether no yield is necessary.
Declaration
public bool IsCompleted { get; }
Property Value
Type | Description |
---|---|
bool |
|
Methods
GetAwaiter()
Gets the TaskSchedulerAwaiter.
Declaration
public TaskSchedulerAwaiter GetAwaiter()
Returns
Type | Description |
---|---|
TaskSchedulerAwaiter | Returns this instance. |
GetResult()
Does nothing.
Declaration
public void GetResult()
OnCompleted(Action)
Schedules a continuation to execute using the specified task scheduler.
Declaration
public void OnCompleted(Action continuation)
Parameters
Type | Name | Description |
---|---|---|
Action | continuation | The delegate to invoke. |
SwitchOffMainThreadAsync(CancellationToken)
Switches the execution context off the main thread asynchronously.
Declaration
public static TaskSchedulerAwaiter SwitchOffMainThreadAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | A CancellationToken to observe while waiting for the task to complete. |
Returns
Type | Description |
---|---|
TaskSchedulerAwaiter | A TaskSchedulerAwaiter configured to the appropriate TaskScheduler. |
Exceptions
Type | Condition |
---|---|
OperationCanceledException | The token has had cancellation requested. |
UnsafeOnCompleted(Action)
Schedules a continuation to execute using the specified task scheduler without capturing the ExecutionContext.
Declaration
public void UnsafeOnCompleted(Action continuation)
Parameters
Type | Name | Description |
---|---|---|
Action | continuation | The action. |