# SystemTarget Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/)

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

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

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L381)

```csharp
public void Activate(Dictionary<string, object>? requestContext, CancellationToken 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-00ee150f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/deactivate-orleans-deactivationreason-system-threading-cancellationtoken-00ee150f/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L384)

```csharp
public void Deactivate(DeactivationReason deactivationReason, CancellationToken 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.

## Dispose {#dispose-edaeeb0a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/dispose-edaeeb0a/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L391-L397)

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

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

## GetComponent {#getcomponent-1-90c7c395}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/getcomponent-1-90c7c395/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L107-L128)

```csharp
public TComponent? GetComponent<TComponent>()
```

Gets the component with the specified type.

### Returns

The component with the specified type.

## GetExtension {#getextension-1-7a25ae0c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/getextension-1-7a25ae0c/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L335-L347)

```csharp
public TExtensionInterface GetExtension<TExtensionInterface>()
```

Returns the grain extension registered for the provided `TExtensionInterface`.

### Returns

The implementation of the extension which is bound to this grain.

## GetOrSetExtension(Func&lt;TExtension&gt;) {#getorsetextension-2-system-func-textension-d5b9a5ee}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/getorsetextension-2-system-func-textension-d5b9a5ee/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L275-L293)

```csharp
public (TExtension, TExtensionInterface) SystemTarget.GetOrSetExtension<TExtension, TExtensionInterface>(Func<TExtension> newExtensionFunc)
```

Binds an extension to an addressable object, if not already done.

### Parameters

- `newExtensionFunc` (`Func<TExtension>`): A factory function that constructs a new extension object.

### Returns

A tuple, containing first the extension and second an addressable reference to the extension's interface.

## GetTarget {#gettarget-6971be98}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/gettarget-6971be98/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L378)

```csharp
public object? GetTarget()
```

Gets the target instance.

### Returns

The target.

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

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/migrate-system-collections-generic-dictionary-string-object-nullable-system-thre-f2378ca7/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L408)

```csharp
public void Migrate(Dictionary<string, object>? requestContext, CancellationToken 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-b980162f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/receivemessage-object-b980162f/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L353-L375)

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

Submits an incoming message to this instance.

### Parameters

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

## RegisterGrainTimer(Func&lt;CancellationToken, Task&gt;, TimeSpan, TimeSpan) {#registergraintimer-system-func-system-threading-cancellationtoken-system-threadi-33f688fd}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/registergraintimer-system-func-system-threading-cancellationtoken-system-threadi-33f688fd/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L215-L219)

```csharp
public IGrainTimer RegisterGrainTimer(Func<CancellationToken, Task> callback, TimeSpan dueTime, TimeSpan period)
```

Registers a timer to send regular callbacks to this system target.

### Parameters

- `callback` (`Func<CancellationToken, Task>`): The timer callback, which will fire whenever the timer becomes due.
- `dueTime` (`TimeSpan`): The amount of time to delay before the `callback` is invoked. Specify `System.Threading.Timeout.InfiniteTimeSpan` to prevent the timer from starting. Specify `System.TimeSpan.Zero` to invoke the callback promptly.
- `period` (`TimeSpan`): The time interval between invocations of `callback`. Specify `System.Threading.Timeout.InfiniteTimeSpan` to disable periodic signaling.

### Returns

An `System.IDisposable` object which will cancel the timer upon disposal.

## RegisterGrainTimer(Func&lt;TState, CancellationToken, Task&gt;, TState, TimeSpan, TimeSpan) {#registergraintimer-1-system-func-tstate-system-threading-cancellationtoken-syste-1f7ed765}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/registergraintimer-1-system-func-tstate-system-threading-cancellationtoken-syste-1f7ed765/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L242-L246)

```csharp
public IGrainTimer RegisterGrainTimer<TState>(Func<TState, CancellationToken, Task> callback, TState state, TimeSpan dueTime, TimeSpan period)
```

Registers a timer to send regular callbacks to this grain. This timer will keep the current grain from being deactivated.

### Parameters

- `callback` (`Func<TState, CancellationToken, Task>`): The timer callback, which will fire whenever the timer becomes due.
- `state` (`TState`): The state object passed to the callback.
- `dueTime` (`TimeSpan`): The amount of time to delay before the `callback` is invoked. Specify `System.Threading.Timeout.InfiniteTimeSpan` to prevent the timer from starting. Specify `System.TimeSpan.Zero` to invoke the callback promptly.
- `period` (`TimeSpan`): The time interval between invocations of `callback`. Specify `System.Threading.Timeout.InfiniteTimeSpan` to disable periodic signaling.

### Returns

An `System.IDisposable` object which will cancel the timer upon disposal.

## RegisterTimer(Func&lt;object?, Task&gt;, object?, TimeSpan, TimeSpan) {#registertimer-system-func-object-nullable-system-threading-tasks-task-object-nul-78cefed9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/registertimer-system-func-object-nullable-system-threading-tasks-task-object-nul-78cefed9/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L191-L194)

```csharp
public IGrainTimer RegisterTimer(Func<object?, Task> callback, object? state, TimeSpan dueTime, TimeSpan period)
```

Registers a timer to send regular callbacks to this system target.

### Parameters

- `callback` (`Func<object?, Task>`): The timer callback, which will fire whenever the timer becomes due.
- `state` (`object?`): The state object passed to the callback.
- `dueTime` (`TimeSpan`): The amount of time to delay before the `callback` is invoked. Specify `System.Threading.Timeout.InfiniteTimeSpan` to prevent the timer from starting. Specify `System.TimeSpan.Zero` to invoke the callback promptly.
- `period` (`TimeSpan`): The time interval between invocations of `callback`. Specify `System.Threading.Timeout.InfiniteTimeSpan` to disable periodic signaling.

### Returns

An `System.IDisposable` object which will cancel the timer upon disposal.

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

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/rehydrate-orleans-runtime-irehydrationcontext-7a09b31b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L402-L403)

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

Start rehydrating this instance from the provided rehydration context.

### Parameters

- `context` (`IRehydrationContext`)

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

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/setcomponent-1-tcomponent-nullable-5383c46a/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L134-L146)

```csharp
public void SetComponent<TComponent>(TComponent? instance)
```

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

### Parameters

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

## ToString {#tostring-b40d0f00}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.systemtarget/methods/tostring-b40d0f00/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Core/SystemTarget.cs#L250)

```csharp
public sealed override string ToString()
```

Returns a string that represents the current object.

### Returns

A string that represents the current object.
