Skip to content

LifecycleSubject Methods

Provides functionality for observing a lifecycle.

GetStageName(int)

virtual
View source
protected virtual string GetStageName(int stage)
Gets the name of the specified numeric stage.

Parameters

stageint
The stage number.

Returns

The name of the stage.

GetStageNames(Type)

static
View source
protected static ImmutableDictionary<int, string> GetStageNames(Type type)
Gets the collection of all stage numbers and their corresponding names.

Parameters

typeType
The lifecycle stage class.

Returns

The collection of all stage numbers and their corresponding names.

OnStart(CancellationToken)

virtual
View source
public virtual Task OnStart(CancellationToken cancellationToken = default(CancellationToken))
Handle start notifications.

Parameters

cancellationTokenCancellationToken
The cancellation token which indicates that the operation should be aborted promptly when it is canceled.

Returns

A System.Threading.Tasks.Task which represents the operation.

OnStop(CancellationToken)

virtual
View source
public virtual Task OnStop(CancellationToken cancellationToken = default(CancellationToken))
Handle stop notifications.

Parameters

cancellationTokenCancellationToken
The cancellation token which indicates that the operation should be stopped promptly when it is canceled.

Returns

A System.Threading.Tasks.Task which represents the operation.

Subscribe(string, int, ILifecycleObserver)

virtual
View source
public virtual IDisposable Subscribe(string observerName, int stage, ILifecycleObserver observer)
Subscribe for notification when a stage is reached while starting or stopping.

Parameters

observerNamestring
The name of the observer, for reporting purposes.
stageint
The stage of to subscribe to.
observerILifecycleObserver
The observer.

Returns

A disposable that can be disposed of to unsubscribe.