# TestCluster Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/)

## DeactivateAsync(GrainId) {#deactivateasync-orleans-runtime-grainid-a00d0fa2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/deactivateasync-orleans-runtime-grainid-a00d0fa2/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L273)

```csharp
public Task DeactivateAsync(GrainId grainId)
```

Deactivates the current activation of the specified grain and waits for deactivation to complete.

### Parameters

- `grainId` (`GrainId`): The ID of the grain to deactivate.

### Returns

A task that completes when the grain has been deactivated.

### Examples

```csharp
await cluster.DeactivateAsync(grain.GetGrainId());
```

## DeactivateAsync(IAddressable) {#deactivateasync-orleans-runtime-iaddressable-ca38fd22}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/deactivateasync-orleans-runtime-iaddressable-ca38fd22/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L273)

```csharp
public Task DeactivateAsync(IAddressable grain)
```

Deactivates the current activation of the specified grain and waits for deactivation to complete.

### Parameters

- `grain` (`IAddressable`): The grain to deactivate.

### Returns

A task that completes when the grain has been deactivated.

### Examples

```csharp
await cluster.DeactivateAsync(grain.GetGrainId());
```

## DefaultCreateSiloAsync(string, IConfiguration) {#defaultcreatesiloasync-string-microsoft-extensions-configuration-iconfiguration-4f4fa175}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/defaultcreatesiloasync-string-microsoft-extensions-configuration-iconfiguration-4f4fa175/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L847-L877)

```csharp
public Task<SiloHandle> DefaultCreateSiloAsync(string siloName, IConfiguration configuration)
```

Default value for [TestCluster](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/), which creates a new silo handle.

### Parameters

- `siloName` (`string`): Name of the silo.
- `configuration` (`IConfiguration`): The configuration.

### Returns

The silo handle.

## Deploy {#deploy-9b52de7e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/deploy-9b52de7e/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L288-L289)

```csharp
public void Deploy()
```

Deploys the cluster using the specified configuration and starts the client in-process. It will start the number of silos defined in [TestClusterOptions](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testclusteroptions/).

## DeployAsync {#deployasync-a87abe73}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/deployasync-a87abe73/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L296-L341)

```csharp
public Task DeployAsync()
```

Deploys the cluster using the specified configuration and starts the client in-process.

## Dispose {#dispose-0e48dc68}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/dispose-0e48dc68/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L997-L1003)

```csharp
public void Dispose()
```

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

## DisposeAsync {#disposeasync-04d86e40}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/disposeasync-04d86e40/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs)

```csharp
public ValueTask DisposeAsync()
```

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

### Returns

A task that represents the asynchronous dispose operation.

## GetActiveSilos {#getactivesilos-283e8449}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/getactivesilos-283e8449/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L387-L403)

```csharp
public IEnumerable<SiloHandle> GetActiveSilos()
```

Get the list of current active silos.

### Returns

List of current silos.

## GetLivenessStabilizationTime(ClusterMembershipOptions, bool) {#getlivenessstabilizationtime-orleans-configuration-clustermembershipoptions-bool-aa019a4c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/getlivenessstabilizationtime-orleans-configuration-clustermembershipoptions-bool-aa019a4c/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L477-L491)

```csharp
public static TimeSpan GetLivenessStabilizationTime(ClusterMembershipOptions clusterMembershipOptions, bool didKill = false)
```

Get the timeout value to use to wait for the silo liveness sub-system to detect and act on any recent cluster membership changes.

### Parameters

- `clusterMembershipOptions` (`ClusterMembershipOptions`)
- `didKill` (`bool`)

## GetLog {#getlog-a68e569e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/getlog-a68e569e/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L946)

```csharp
public string GetLog()
```

Gets the log.

### Returns

The log contents.

## GetSiloForAddress(SiloAddress) {#getsiloforaddress-orleans-runtime-siloaddress-1c6e6e3b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/getsiloforaddress-orleans-runtime-siloaddress-1c6e6e3b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L412-L414)

```csharp
public SiloHandle? GetSiloForAddress(SiloAddress siloAddress)
```

Find the silo handle for the specified silo address.

### Parameters

- `siloAddress` (`SiloAddress`): Silo address to be found.

### Returns

SiloHandle of the appropriate silo, or `null` if not found.

## GetSiloServiceProvider(SiloAddress) {#getsiloserviceprovider-orleans-runtime-siloaddress-f7a0741f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/getsiloserviceprovider-orleans-runtime-siloaddress-f7a0741f/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L158-L167)

```csharp
public IServiceProvider GetSiloServiceProvider(SiloAddress silo = null)
```

Returns the `System.IServiceProvider` associated with the given `silo`.

### Parameters

- `silo` (`SiloAddress`): The silo process to the the service provider for.

## InitializeClientAsync {#initializeclientasync-014b493d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/initializeclientasync-014b493d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L739-L808)

```csharp
public Task InitializeClientAsync()
```

Initialize the grain client. This should be already done by [TestCluster](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/) or [TestCluster](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/)

## KillClientAsync {#killclientasync-7c73a0ff}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/killclientasync-7c73a0ff/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L670-L685)

```csharp
public Task KillClientAsync()
```

Performs a hard kill on client. Client will not cleanup resources.

## KillSiloAsync(SiloHandle) {#killsiloasync-orleans-testinghost-silohandle-bd02b21f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/killsiloasync-orleans-testinghost-silohandle-bd02b21f/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L647-L663)

```csharp
public Task KillSiloAsync(SiloHandle instance)
```

Do an immediate Kill of the specified silo.

### Parameters

- `instance` (`SiloHandle`): Silo to be killed.

## MigrateAsync(GrainId, SiloAddress?) {#migrateasync-orleans-runtime-grainid-orleans-runtime-siloaddress-nullable-6369b8f7}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/migrateasync-orleans-runtime-grainid-orleans-runtime-siloaddress-nullable-6369b8f7/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L279)

```csharp
public Task MigrateAsync(GrainId grainId, SiloAddress? targetSilo = null)
```

Migrates the current activation of the specified grain to a different silo and waits for migration to complete. If `targetSilo` is specified, a placement hint is set to guide migration to that silo.

### Parameters

- `grainId` (`GrainId`): The ID of the grain to migrate.
- `targetSilo` (`SiloAddress?`): The target silo address, or `null` to let the placement director choose.

### Returns

A task that completes when the grain has been migrated (deactivated on the source silo).

### Examples

```csharp
var targetSilo = cluster.GetActiveSilos().First(s => s.SiloAddress != originalHost).SiloAddress;
            await cluster.MigrateAsync(grain.GetGrainId(), targetSilo);
```

## MigrateAsync(IAddressable, SiloAddress?) {#migrateasync-orleans-runtime-iaddressable-orleans-runtime-siloaddress-nullable-22710b01}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/migrateasync-orleans-runtime-iaddressable-orleans-runtime-siloaddress-nullable-22710b01/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L279)

```csharp
public Task MigrateAsync(IAddressable grain, SiloAddress? targetSilo = null)
```

Migrates the current activation of the specified grain to a different silo and waits for migration to complete. If `targetSilo` is specified, a placement hint is set to guide migration to that silo.

### Parameters

- `grain` (`IAddressable`): The grain to migrate.
- `targetSilo` (`SiloAddress?`): The target silo address, or `null` to let the placement director choose.

### Returns

A task that completes when the grain has been migrated (deactivated on the source silo).

### Examples

```csharp
var targetSilo = cluster.GetActiveSilos().First(s => s.SiloAddress != originalHost).SiloAddress;
            await cluster.MigrateAsync(grain.GetGrainId(), targetSilo);
```

## RestartSiloAsync(SiloHandle) {#restartsiloasync-orleans-testinghost-silohandle-69932e82}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/restartsiloasync-orleans-testinghost-silohandle-69932e82/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L693-L716)

```csharp
public Task<SiloHandle?> RestartSiloAsync(SiloHandle instance)
```

Do a Stop or Kill of the specified silo, followed by a restart.

### Parameters

- `instance` (`SiloHandle`): Silo to be restarted.

## RestartStoppedSecondarySiloAsync(string) {#restartstoppedsecondarysiloasync-string-df78143d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/restartstoppedsecondarysiloasync-string-df78143d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L724-L732)

```csharp
public Task<SiloHandle> RestartStoppedSecondarySiloAsync(string siloName)
```

Restart a previously stopped.

### Parameters

- `siloName` (`string`): Silo to be restarted.

## StartAdditionalSilo(bool) {#startadditionalsilo-bool-29a85f80}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/startadditionalsilo-bool-29a85f80/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L500)

```csharp
public SiloHandle StartAdditionalSilo(bool startAdditionalSiloOnNewPort = false)
```

Start an additional silo, so that it joins the existing cluster.

### Parameters

- `startAdditionalSiloOnNewPort` (`bool`)

### Returns

SiloHandle for the newly started silo.

## StartAdditionalSiloAsync(bool) {#startadditionalsiloasync-bool-b6e72487}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/startadditionalsiloasync-bool-b6e72487/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L509-L510)

```csharp
public Task<SiloHandle> StartAdditionalSiloAsync(bool startAdditionalSiloOnNewPort = false)
```

Start an additional silo, so that it joins the existing cluster.

### Parameters

- `startAdditionalSiloOnNewPort` (`bool`)

### Returns

SiloHandle for the newly started silo.

## StartAdditionalSilosAsync(int, bool) {#startadditionalsilosasync-int-bool-90a14c74}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/startadditionalsilosasync-int-bool-90a14c74/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L520-L548)

```csharp
public Task<List<SiloHandle>> StartAdditionalSilosAsync(int silosToStart, bool startAdditionalSiloOnNewPort = false)
```

Start a number of additional silo, so that they join the existing cluster.

### Parameters

- `silosToStart` (`int`): Number of silos to start.
- `startAdditionalSiloOnNewPort` (`bool`)

### Returns

List of SiloHandles for the newly started silos.

## StartSiloAsync(int, TestClusterOptions, IReadOnlyList&lt;IConfigurationSource&gt;, bool) {#startsiloasync-int-orleans-testinghost-testclusteroptions-system-collections-gen-31da1389}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/startsiloasync-int-orleans-testinghost-testclusteroptions-system-collections-gen-31da1389/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs)

```csharp
public Task<SiloHandle> StartSiloAsync(int instanceNumber, TestClusterOptions clusterOptions, IReadOnlyList<IConfigurationSource>? configurationOverrides = null, bool startSiloOnNewPort = false)
```

Starts a new silo.

### Parameters

- `instanceNumber` (`int`): The instance number to deploy
- `clusterOptions` (`TestClusterOptions`): The options to use.
- `configurationOverrides` (`IReadOnlyList<IConfigurationSource>`): Configuration overrides.
- `startSiloOnNewPort` (`bool`): Whether we start this silo on a new port, instead of the default one

### Returns

A handle to the deployed silo.

## StartSiloAsync(TestCluster, int, TestClusterOptions, IReadOnlyList&lt;IConfigurationSource&gt;, bool) {#startsiloasync-orleans-testinghost-testcluster-int-orleans-testinghost-testclust-f05dbb39}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/startsiloasync-orleans-testinghost-testcluster-int-orleans-testinghost-testclust-f05dbb39/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs)

```csharp
public static Task<SiloHandle> StartSiloAsync(TestCluster cluster, int instanceNumber, TestClusterOptions clusterOptions, IReadOnlyList<IConfigurationSource>? configurationOverrides = null, bool startSiloOnNewPort = false)
```

Start a new silo in the target cluster

### Parameters

- `cluster` (`TestCluster`): The TestCluster in which the silo should be deployed
- `instanceNumber` (`int`): The instance number to deploy
- `clusterOptions` (`TestClusterOptions`): The options to use.
- `configurationOverrides` (`IReadOnlyList<IConfigurationSource>`): Configuration overrides.
- `startSiloOnNewPort` (`bool`): Whether we start this silo on a new port, instead of the default one

### Returns

A handle to the silo deployed

## StopAllSilos {#stopallsilos-49d0eb32}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/stopallsilos-49d0eb32/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L601-L602)

```csharp
public void StopAllSilos()
```

Stop all current silos.

## StopAllSilosAsync {#stopallsilosasync-8ae3b417}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/stopallsilosasync-8ae3b417/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L609-L616)

```csharp
public Task StopAllSilosAsync()
```

Stop all current silos.

## StopClusterClientAsync {#stopclusterclientasync-0cbb6af7}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/stopclusterclientasync-0cbb6af7/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L577-L594)

```csharp
public Task StopClusterClientAsync()
```

Stop cluster client as an asynchronous operation.

### Returns

A `System.Threading.Tasks.Task` representing the asynchronous operation.

## StopPrimarySiloAsync {#stopprimarysiloasync-a5bfca01}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/stopprimarysiloasync-a5bfca01/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L566-L569)

```csharp
public Task StopPrimarySiloAsync()
```

Stops the default Primary silo.

## StopSecondarySilosAsync {#stopsecondarysilosasync-138d31f6}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/stopsecondarysilosasync-138d31f6/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L555-L559)

```csharp
public Task StopSecondarySilosAsync()
```

Stop any additional silos, not including the default Primary silo.

## StopSiloAsync(SiloHandle) {#stopsiloasync-orleans-testinghost-silohandle-f43cad87}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/stopsiloasync-orleans-testinghost-silohandle-f43cad87/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs)

```csharp
public Task StopSiloAsync(SiloHandle instance)
```

Do a semi-graceful Stop of the specified silo.

### Parameters

- `instance` (`SiloHandle`): Silo to be stopped.

## TryGetGrainContext(GrainId, IGrainContext?) {#trygetgraincontext-orleans-runtime-grainid-out-orleans-runtime-igraincontext-nul-fdbd0842}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/trygetgraincontext-orleans-runtime-grainid-out-orleans-runtime-igraincontext-nul-fdbd0842/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L181-L193)

```csharp
public bool TryGetGrainContext(GrainId grainId, out IGrainContext? grainContext)
```

Attempts to find the [IGrainContext](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraincontext/) for the grain with the specified `grainId` by searching all silos in the cluster.

### Parameters

- `grainId` (`GrainId`): The ID of the grain to find.
- `grainContext` (`IGrainContext?`): When this method returns, contains the grain context if found; otherwise, `null`.

### Returns

`true` if the grain was found in one of the silos; otherwise, `false`.

## WaitForClusterManifestToStabilizeAsync(bool) {#waitforclustermanifesttostabilizeasync-bool-1c071ac2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/waitforclustermanifesttostabilizeasync-bool-1c071ac2/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L455-L469)

```csharp
public Task WaitForClusterManifestToStabilizeAsync(bool didKill = false)
```

Wait for active silos to observe cluster manifest updates for all active silos.

### Parameters

- `didKill` (`bool`): Whether recent membership changes were done by graceful Stop.

## WaitForDeactivationAsync(GrainId) {#waitfordeactivationasync-orleans-runtime-grainid-c72de505}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/waitfordeactivationasync-orleans-runtime-grainid-c72de505/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L215-L220)

```csharp
public Task WaitForDeactivationAsync(GrainId grainId)
```

Gets a `System.Threading.Tasks.Task` that completes when the current activation of the specified grain finishes deactivating. If the grain is not currently activated, returns `System.Threading.Tasks.Task.CompletedTask`.

### Parameters

- `grainId` (`GrainId`): The ID of the grain to observe.

### Returns

A task that completes when the grain's current activation has deactivated.

### Examples

```csharp
var deactivated = cluster.WaitForDeactivationAsync(grain.GetGrainId());
            await grain.DoDeactivate();
            await deactivated;
```

## WaitForDeactivationAsync(IAddressable) {#waitfordeactivationasync-orleans-runtime-iaddressable-7eb90623}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/waitfordeactivationasync-orleans-runtime-iaddressable-7eb90623/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L269)

```csharp
public Task WaitForDeactivationAsync(IAddressable grain)
```

Gets a `System.Threading.Tasks.Task` that completes when the current activation of the specified grain finishes deactivating. If the grain is not currently activated, returns `System.Threading.Tasks.Task.CompletedTask`.

### Parameters

- `grain` (`IAddressable`): The grain to observe.

### Returns

A task that completes when the grain's current activation has deactivated.

### Examples

```csharp
var deactivated = cluster.WaitForDeactivationAsync(grain.GetGrainId());
            await grain.DoDeactivate();
            await deactivated;
```

## WaitForLivenessToStabilizeAsync(bool) {#waitforlivenesstostabilizeasync-bool-e1ef88fe}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.testinghost/orleans.testinghost.testcluster/methods/waitforlivenesstostabilizeasync-bool-e1ef88fe/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.TestingHost/TestCluster.cs#L423-L437)

```csharp
public Task WaitForLivenessToStabilizeAsync(bool didKill = false)
```

Wait for the silo liveness sub-system to detect and act on any recent cluster membership changes.

### Parameters

- `didKill` (`bool`): Whether recent membership changes we done by graceful Stop.
