Dela via


IActorStateManager.AddOrUpdateStateAsync<T> Method

Definition

Adds an actor state with given state name, if it does not already exist or updates the state with specified state name, if it exists.

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

Type Parameters

T

Type of value associated with given state name.

Parameters

stateName
String

Name of the actor state to add or update.

addValue
T

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

updateValueFactory
Func<String,T,T>

Factory function to generate value of actor state to update if it exists.

cancellationToken
CancellationToken

The token to monitor for cancellation requests.

Returns

Task<T>

A task that represents the asynchronous add/update operation. The value of TResult parameter contains value of actor state that was added/updated.

Exceptions

The specified state name is null.

The operation was canceled.

Remarks

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

Applies to