Table of Contents

Class UIThreadFixtureBase

Namespace
Xunit
Assembly
Xunit.StaFact.dll

Provides a shared UI thread for tests in an xUnit class or collection fixture.

public abstract class UIThreadFixtureBase : IAsyncLifetime, IAsyncDisposable
Inheritance
UIThreadFixtureBase
Implements
IAsyncLifetime
Derived
Inherited Members

Remarks

Derive from one of the concrete fixture types rather than deriving from this type directly.

Properties

SynchronizationContext

Gets the synchronization context for the shared UI thread.

protected SynchronizationContext SynchronizationContext { get; }

Property Value

SynchronizationContext

Methods

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

DisposeOnUIThreadAsync()

Disposes the fixture on its shared UI thread.

protected virtual ValueTask DisposeOnUIThreadAsync()

Returns

ValueTask

A task that completes when disposal has finished.

Remarks

StaThreadFixture does not install a synchronization context, so code after a yielding await may resume on a thread-pool thread.

InitializeAsync()

Called immediately after the class has been created, before it is used.

public ValueTask InitializeAsync()

Returns

ValueTask

InitializeOnUIThreadAsync()

Initializes the fixture on its shared UI thread.

protected virtual ValueTask InitializeOnUIThreadAsync()

Returns

ValueTask

A task that completes when initialization has finished.

Remarks

StaThreadFixture does not install a synchronization context, so code after a yielding await may resume on a thread-pool thread.

RunOnUIThreadAsync(Func<ValueTask>)

Runs a callback on the shared UI thread.

protected ValueTask RunOnUIThreadAsync(Func<ValueTask> callback)

Parameters

callback Func<ValueTask>

The callback to run.

Returns

ValueTask

A task that completes when the callback has finished.