AsyncContext.From(SynchronizationContext) method¶
Defined in
Type: AsyncContext
Namespace: ReactiveUI.Extensions.Async
Assembly: ReactiveUI.Extensions.dll
Applies to
net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481
Overloads¶
- 1.
public static AsyncContext From(SynchronizationContext synchronizationContext) - 2.
public static AsyncContext From(TaskScheduler taskScheduler) - 3.
public static AsyncContext From(IScheduler scheduler)
1. Overload¶
public static AsyncContext From(SynchronizationContext synchronizationContext)
Summary: Creates a new AsyncContext that uses the specified SynchronizationContext for asynchronous operations.
Parameters
| Name | Type | Description |
|---|---|---|
synchronizationContext | SynchronizationContext | The SynchronizationContext to associate with the AsyncContext. Cannot be null. |
Returns: AsyncContext -- An AsyncContext instance configured to use the provided SynchronizationContext.
Remarks
The returned AsyncContext will have its TaskScheduler property set to null. Use this method when you want to control asynchronous execution using a specific SynchronizationContext, such as for UI thread synchronization.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if synchronizationContext is null. |
2. Overload¶
public static AsyncContext From(TaskScheduler taskScheduler)
Summary: Creates a new AsyncContext that uses the specified TaskScheduler for task execution.
Parameters
| Name | Type | Description |
|---|---|---|
taskScheduler | TaskScheduler | The TaskScheduler to associate with the new AsyncContext. Cannot be null. |
Returns: AsyncContext -- An AsyncContext instance configured to use the specified TaskScheduler. The SynchronizationContext property of the returned instance is set to null.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if taskScheduler is null. |
3. Overload¶
public static AsyncContext From(IScheduler scheduler)
Summary: Creates a new AsyncContext using the specified scheduler for task and synchronization context management.
Parameters
| Name | Type | Description |
|---|---|---|
scheduler | [IScheduler](# | The scheduler to use for configuring the AsyncContext. |
Returns: AsyncContext -- An AsyncContext instance configured with the provided scheduler.
Remarks
If the provided scheduler directly implements SynchronizationContext or TaskScheduler, those instances are used directly. Otherwise, the scheduler is wrapped in a TaskScheduler adapter that delegates task execution to the scheduler.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if scheduler is null. |