# IGrainContext Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraincontext/)

## Activate(Dictionary&lt;string, object&gt;, CancellationToken) {#activate-system-collections-generic-dictionary-string-object-nullable-system-thr-e7173ae1}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraincontext/methods/activate-system-collections-generic-dictionary-string-object-nullable-system-thr-e7173ae1/)

```csharp
public abstract void Activate(Dictionary<string, object>? requestContext, CancellationToken cancellationToken = default(CancellationToken))
```

Start activating this instance.

### Parameters

- `requestContext` (`Dictionary<string, object>`): The request context of the request which is causing this instance to be activated, if any.
- `cancellationToken` (`CancellationToken`): A cancellation token which, when canceled, indicates that the process should complete promptly.

## Deactivate(DeactivationReason, CancellationToken) {#deactivate-orleans-deactivationreason-system-threading-cancellationtoken-65f3d00f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraincontext/methods/deactivate-orleans-deactivationreason-system-threading-cancellationtoken-65f3d00f/)

```csharp
public abstract void Deactivate(DeactivationReason deactivationReason, CancellationToken cancellationToken = default(CancellationToken))
```

Start deactivating this instance.

### Parameters

- `deactivationReason` (`DeactivationReason`): The reason for deactivation, for informational purposes.
- `cancellationToken` (`CancellationToken`): A cancellation token which, when canceled, indicates that the process should complete promptly.

## Migrate(Dictionary&lt;string, object&gt;, CancellationToken) {#migrate-system-collections-generic-dictionary-string-object-nullable-system-thre-3cae54ff}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraincontext/methods/migrate-system-collections-generic-dictionary-string-object-nullable-system-thre-3cae54ff/)

```csharp
public abstract void Migrate(Dictionary<string, object>? requestContext, CancellationToken cancellationToken = default(CancellationToken))
```

Starts an attempt to migrating this instance to another location. Migration captures the current [RequestContext](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.requestcontext/), making it available to the activation's placement director so that it can consider it when selecting a new location. Migration will occur asynchronously, when no requests are executing, and will not occur if the activation's placement director does not select an alternative location.

### Parameters

- `requestContext` (`Dictionary<string, object>`): The request context, which is provided to the placement director so that it can be examined when selecting a new location.
- `cancellationToken` (`CancellationToken`): A cancellation token which, when canceled, indicates that the process should complete promptly.

## ReceiveMessage(object) {#receivemessage-object-66048c92}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraincontext/methods/receivemessage-object-66048c92/)

```csharp
public abstract void ReceiveMessage(object message)
```

Submits an incoming message to this instance.

### Parameters

- `message` (`object`): The message.

## Rehydrate(IRehydrationContext) {#rehydrate-orleans-runtime-irehydrationcontext-e7a43f12}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraincontext/methods/rehydrate-orleans-runtime-irehydrationcontext-e7a43f12/)

```csharp
public abstract void Rehydrate(IRehydrationContext context)
```

Start rehydrating this instance from the provided rehydration context.

### Parameters

- `context` (`IRehydrationContext`)

## SetComponent(TComponent?) {#setcomponent-1-tcomponent-nullable-e51f7c17}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.igraincontext/methods/setcomponent-1-tcomponent-nullable-e51f7c17/)

```csharp
public abstract void SetComponent<TComponent>(TComponent? value)
```

Sets the provided value as the component for type `TComponent`.

### Parameters

- `value` (`TComponent?`): The component instance.
