IReliableDictionary<TKey,TValue>.TryUpdateAsync Method

Definition

Overloads

TryUpdateAsync(ITransaction, TKey, TValue, TValue)

Compares the existing value for the specified key with a specified value, and if they are equal, updates the key with a third value.

TryUpdateAsync(ITransaction, TKey, TValue, TValue, TimeSpan, CancellationToken)

Compares the existing value for the specified key with a specified value, and if they are equal, updates the key with a third value.

TryUpdateAsync(ITransaction, TKey, TValue, TValue)

Compares the existing value for the specified key with a specified value, and if they are equal, updates the key with a third value.

public System.Threading.Tasks.Task<bool> TryUpdateAsync (Microsoft.ServiceFabric.Data.ITransaction tx, TKey key, TValue newValue, TValue comparisonValue);
abstract member TryUpdateAsync : Microsoft.ServiceFabric.Data.ITransaction * 'Key * 'Value * 'Value -> System.Threading.Tasks.Task<bool>
Public Function TryUpdateAsync (tx As ITransaction, key As TKey, newValue As TValue, comparisonValue As TValue) As Task(Of Boolean)

Parameters

tx
ITransaction

Transaction to associate this operation with.

key
TKey

The key whose value is compared with comparisonValue and possibly replaced.

newValue
TValue

The value that replaces the value of the element that has the specified key if the comparison results in equality.

comparisonValue
TValue

The value that is compared to the value of the element that has the specified key.

Returns

Task<Boolean>

A task that represents the asynchronous update operation. The task result indicates whether the object was updated.

Exceptions

tx is null, or key is null or cannot be serialized.

The operation failed to complete within the default timeout.

The exception that is thrown when the IReliableDictionary<TKey,TValue> is not in Primary.

The transaction has been internally faulted by the system. Retry the operation on a new transaction

Thrown when a method call is invalid for the object's current state. Example, transaction used is already terminated: committed or aborted by the user. If this exception is thrown, it is highly likely that there is a bug in the service code of the use of transactions.

Indicates that the Reliable Dictionary is closed or deleted.

Applies to

Product Introduced

TryUpdateAsync(ITransaction, TKey, TValue, TValue, TimeSpan, CancellationToken)

Compares the existing value for the specified key with a specified value, and if they are equal, updates the key with a third value.

public System.Threading.Tasks.Task<bool> TryUpdateAsync (Microsoft.ServiceFabric.Data.ITransaction tx, TKey key, TValue newValue, TValue comparisonValue, TimeSpan timeout, System.Threading.CancellationToken cancellationToken);
abstract member TryUpdateAsync : Microsoft.ServiceFabric.Data.ITransaction * 'Key * 'Value * 'Value * TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<bool>

Parameters

tx
ITransaction

Transaction to associate this operation with.

key
TKey

The key whose value is compared with comparisonValue and possibly replaced.

newValue
TValue

The value that replaces the value of the element that has the specified key if the comparison results in equality.

comparisonValue
TValue

The value that is compared to the value of the element that has the specified key.

timeout
TimeSpan

The amount of time to wait for the operation to complete before throwing a TimeoutException. Primarily used to prevent deadlocks. The default is 4 seconds.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default is None.

Returns

Task<Boolean>

A task that represents the asynchronous update operation. The task result indicates whether the object was updated.

Exceptions

tx is null, or key is null or cannot be serialized.

timeout is negative.

The operation failed to complete within the given timeout.

The operation was canceled.

The exception that is thrown when the IReliableDictionary<TKey,TValue> is not in Primary.

The transaction has been internally faulted by the system. Retry the operation on a new transaction

Thrown when a method call is invalid for the object's current state. Example, transaction used is already terminated: committed or aborted by the user. If this exception is thrown, it is highly likely that there is a bug in the service code of the use of transactions.

Indicates that the Reliable Dictionary is closed or deleted.

Applies to

Product Introduced