Skip to content

LifecycleExtensions Methods

Extensions for working with lifecycle observers.

Subscribe(ILifecycleObservable, int, ILifecycleObserver)

staticextension
View source
public static IDisposable Subscribe(this ILifecycleObservable observable, int stage, ILifecycleObserver observer)
Creates a disposable subscription to the lifecycle.

Parameters

observableILifecycleObservable
The lifecycle observable.
stageint
The stage to participate in.
observerILifecycleObserver
The observer.

Returns

A System.IDisposable instance which can be disposed to unsubscribe the observer from the lifecycle.

Subscribe(ILifecycleObservable, string, int, Func<CancellationToken, Task>)

staticextension
View source
public static IDisposable Subscribe(this ILifecycleObservable observable, string observerName, int stage, Func<CancellationToken, Task> onStart)
Creates a disposable subscription to the lifecycle.

Parameters

observableILifecycleObservable
The lifecycle observable.
observerNamestring
The name of the observer.
stageint
The stage to participate in.
onStartFunc<CancellationToken, Task>
The delegate called when starting the specified lifecycle stage.

Returns

A System.IDisposable instance which can be disposed to unsubscribe the observer from the lifecycle.

Subscribe(ILifecycleObservable, string, int, Func<CancellationToken, Task>, Func<CancellationToken, Task>)

staticextension
View source
public static IDisposable Subscribe(this ILifecycleObservable observable, string observerName, int stage, Func<CancellationToken, Task> onStart, Func<CancellationToken, Task>? onStop)
Creates a disposable subscription to the lifecycle.

Parameters

observableILifecycleObservable
The lifecycle observable.
observerNamestring
The name of the observer.
stageint
The stage to participate in.
onStartFunc<CancellationToken, Task>
The delegate called when starting the specified lifecycle stage.
onStopFunc<CancellationToken, Task>
The delegate to be called when stopping the specified lifecycle stage.

Returns

A System.IDisposable instance which can be disposed to unsubscribe the observer from the lifecycle.

Subscribe(ILifecycleObservable, int, Func<CancellationToken, Task>)

staticextension
View source
public static IDisposable Subscribe<TObserver>(this ILifecycleObservable observable, int stage, Func<CancellationToken, Task> onStart)
Creates a disposable subscription to the lifecycle.

Parameters

observableILifecycleObservable
The lifecycle observable.
stageint
The stage to participate in.
onStartFunc<CancellationToken, Task>
The delegate called when starting the specified lifecycle stage.

Returns

A System.IDisposable instance which can be disposed to unsubscribe the observer from the lifecycle.

Subscribe(ILifecycleObservable, int, Func<CancellationToken, Task>, Func<CancellationToken, Task>)

staticextension
View source
public static IDisposable Subscribe<TObserver>(this ILifecycleObservable observable, int stage, Func<CancellationToken, Task> onStart, Func<CancellationToken, Task> onStop)
Creates a disposable subscription to the lifecycle.

Parameters

observableILifecycleObservable
The lifecycle observable.
stageint
The stage to participate in.
onStartFunc<CancellationToken, Task>
The delegate called when starting the specified lifecycle stage.
onStopFunc<CancellationToken, Task>
Teh delegate to be called when stopping the specified lifecycle stage.

Returns

A System.IDisposable instance which can be disposed to unsubscribe the observer from the lifecycle.

Subscribe(ILifecycleObservable, int, ILifecycleObserver)

staticextension
View source
public static IDisposable Subscribe<TObserver>(this ILifecycleObservable observable, int stage, ILifecycleObserver observer)
Creates a disposable subscription to the lifecycle.

Parameters

observableILifecycleObservable
The lifecycle observable.
stageint
The stage to participate in.
observerILifecycleObserver
The observer.

Returns

A System.IDisposable instance which can be disposed to unsubscribe the observer from the lifecycle.