src/Orleans.Core.Abstractions/Lifecycle/LifecycleExtensions.cs
/// <summary>
/// Creates a disposable subscription to the lifecycle.
/// </summary>
/// <param name="observable">The lifecycle observable.</param>
/// <param name="observerName">The name of the observer.</param>
/// <param name="stage">The stage to participate in.</param>
/// <param name="onStart">The delegate called when starting the specified lifecycle stage.</param>
/// <param name="onStop">Teh delegate to be called when stopping the specified lifecycle stage.</param>
/// <returns>A <see cref="IDisposable"/> instance which can be disposed to unsubscribe the observer from the lifecycle.</returns>
Creates a disposable subscription to the lifecycle.
Creates a disposable subscription to the lifecycle .
public static IDisposable Subscribe(this ILifecycleObservable observable, string observerName, int stage, Func<CancellationToken, Task> onStart, Func<CancellationToken, Task> onStop)
        {
            if (observable is null)
            {
                throw new ArgumentNullException(nameof(observable));
            }
            if (onStart is null)
            {
                throw new ArgumentNullException(nameof(onStart));
            }
            if (onStop is null)
            {
                return StartupObserver.Create(observable, observerName, stage, onStart);
            }
            return observable.Subscribe(observerName, stage, new Observer(onStart, onStop));
        }
public static IDisposable Subscribe ( this ILifecycleObservable observable , string observerName , int stage , Func < CancellationToken , Task > onStart , Func < CancellationToken , Task > onStop ) { if ( observable is null ) { throw new ArgumentNullException ( nameof ( observable ) ) ; } if ( onStart is null ) { throw new ArgumentNullException ( nameof ( onStart ) ) ; } if ( onStop is null ) { return StartupObserver . Create ( observable , observerName , stage , onStart ) ; } return observable . Subscribe ( observerName , stage , new Observer ( onStart , onStop ) ) ; }
Creates a disposable subscription to the lifecycle.
Creates a disposable subscription to the lifecycle .
A  instance which can be disposed to unsubscribe the observer from the lifecycle.
A instance which can be disposed to unsubscribe the observer from the lifecycle .
ILifecycleObservable
this
observerName
string
The name of the observer.
The name of the observer .
stage
int
The stage to participate in.
The stage to participate in .
onStart
Func<CancellationToken, Task>
The delegate called when starting the specified lifecycle stage.
The delegate called when starting the specified lifecycle stage .
onStop
Func<CancellationToken, Task>
Teh delegate to be called when stopping the specified lifecycle stage.
Teh delegate to be called when stopping the specified lifecycle stage .
observable
The lifecycle observable.
The lifecycle observable .