Share via


IActorStateManager.TryAddStateAsync<T> Method

Definition

Attempts to add an actor state with given state name and value. Returns false if an actor state with the same name already exists.

public System.Threading.Tasks.Task<bool> TryAddStateAsync<T> (string stateName, T value, System.Threading.CancellationToken cancellationToken = default);
abstract member TryAddStateAsync : string * 'T * System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>
Public Function TryAddStateAsync(Of T) (stateName As String, value As T, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Boolean)

Type Parameters

T

Type of value associated with given state name.

Parameters

stateName
String

Name of the actor state to add.

value
T

Value of the actor state to add.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. This is optional and defaults to None

Returns

A boolean task that represents the asynchronous add operation. Returns true if the value was successfully added and false if an actor state with the same name already exists.

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