IActorStateManager.GetOrAddStateAsync<T>(String, T, CancellationToken) Method

Definition

Gets an actor state with the given state name if it exists. If it does not exist, creates and new state with the specified name and value.

public System.Threading.Tasks.Task<T> GetOrAddStateAsync<T> (string stateName, T value, System.Threading.CancellationToken cancellationToken = null);
abstract member GetOrAddStateAsync : string * 'T * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>

Type Parameters

T

Type of value associated with given state name.

Parameters

stateName
String

Name of the actor state to get or add.

value
T

Value of the actor state to add if it does not exist.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

Returns

Task<T>

A task that represents the asynchronous get or add operation. The value of TResult parameter contains value of actor state with given state name.

Exceptions

The specified state name is null. Provide a valid state name string.

The request was canceled using the specified cancellationToken.

Remarks

The type of state value T must be Data Contract serializable.

Applies to