Skip to content

AsyncContext.From(SynchronizationContext) method

Defined in

Type: AsyncContext Namespace: ReactiveUI.Primitives.Async.Reactive Assembly: ReactiveUI.Primitives.Async.Reactive.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)

View source

Summary: Creates a new AsyncContext that uses the specified SynchronizationContext for asynchronous operations.

Parameters

NameTypeDescription
synchronizationContextSynchronizationContextThe 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

TypeCondition
System.ArgumentNullExceptionThrown if synchronizationContext is null.

2. Overload

public static AsyncContext From(TaskScheduler taskScheduler)

View source

Summary: Creates a new AsyncContext that uses the specified TaskScheduler for task execution.

Parameters

NameTypeDescription
taskSchedulerTaskSchedulerThe 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

TypeCondition
System.ArgumentNullExceptionThrown if taskScheduler is null.

3. Overload

public static AsyncContext From(IScheduler scheduler)

View source

Summary: Creates a new AsyncContext using the specified sequencer for continuation scheduling.

Parameters

NameTypeDescription
scheduler[IScheduler](#The sequencer to use for configuring the AsyncContext.

Returns: AsyncContext -- An AsyncContext instance configured with the provided scheduler.

Remarks

If the provided sequencer directly implements SynchronizationContext, that instance is used directly. Otherwise, continuations are scheduled as direct IWorkItem instances on the sequencer.

Exceptions

TypeCondition
System.ArgumentNullExceptionThrown if scheduler is null.