# LifecycleSubject Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.lifecyclesubject/)

## OnStart(CancellationToken) {#onstart-system-threading-cancellationtoken-8dca693d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.lifecyclesubject/methods/onstart-system-threading-cancellationtoken-8dca693d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Lifecycle/LifecycleSubject.cs#L96-L135)

```csharp
public virtual Task OnStart(CancellationToken cancellationToken = default(CancellationToken))
```

Handle start notifications.

### Parameters

- `cancellationToken` (`CancellationToken`): 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) {#onstop-system-threading-cancellationtoken-3a31a69b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.lifecyclesubject/methods/onstop-system-threading-cancellationtoken-3a31a69b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Lifecycle/LifecycleSubject.cs#L157-L187)

```csharp
public virtual Task OnStop(CancellationToken cancellationToken = default(CancellationToken))
```

Handle stop notifications.

### Parameters

- `cancellationToken` (`CancellationToken`): 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) {#subscribe-string-int-orleans-ilifecycleobserver-ad5cc04b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core/orleans.lifecyclesubject/methods/subscribe-string-int-orleans-ilifecycleobserver-ad5cc04b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core/Lifecycle/LifecycleSubject.cs#L209-L214)

```csharp
public virtual IDisposable Subscribe(string observerName, int stage, ILifecycleObserver observer)
```

Subscribe for notification when a stage is reached while starting or stopping.

### Parameters

- `observerName` (`string`): The name of the observer, for reporting purposes.
- `stage` (`int`): The stage of to subscribe to.
- `observer` (`ILifecycleObserver`): The observer.

### Returns

A disposable that can be disposed of to unsubscribe.
