# LifecycleSubject

Package: [Microsoft.Orleans.Core](/orleans/docs/api/csharp/microsoft.orleans.core/) 10.0.0

[NuGet package](https://www.nuget.org/packages/Microsoft.Orleans.Core) | [Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Lifecycle/LifecycleSubject.cs#L25)

```csharp
public abstract class LifecycleSubject : ILifecycleObservable, ILifecycleObserver, ILifecycleSubject
```

Provides functionality for observing a lifecycle.

## Remarks

- Single use, does not support multiple start/stop cycles.
- Once started, no other observers can be subscribed.
- OnStart starts stages in order until first failure or cancellation.
- OnStop stops states in reverse order starting from highest started stage.
- OnStop stops all stages regardless of errors even if canceled.

## Methods

- [OnStart(CancellationToken)](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.lifecyclesubject/methods/onstart-system-threading-cancellationtoken-8dca693d/)
- [OnStop(CancellationToken)](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.lifecyclesubject/methods/onstop-system-threading-cancellationtoken-3a31a69b/)
- [Subscribe(string, int, ILifecycleObserver)](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.lifecyclesubject/methods/subscribe-string-int-orleans-ilifecycleobserver-ad5cc04b/)
