Share via


RetryPolicy.ExecuteAsync Method (Func, CancellationToken)

Repeatedly executes the specified asynchronous task while it satisfies the current retry policy.

Namespace: Microsoft.WindowsAzure.Common.TransientFaultHandling
Assembly: Microsoft.WindowsAzure.Common (in Microsoft.WindowsAzure.Common.dll)

Usage

'Usage
Dim instance As RetryPolicy
Dim taskFunc As Func(Of Task(Of TResult))
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of TResult)

returnValue = instance.ExecuteAsync(taskFunc, cancellationToken)

Syntax

'Declaration
Public Function ExecuteAsync(Of TResult) ( _
    taskFunc As Func(Of Task(Of TResult)), _
    cancellationToken As CancellationToken _
) As Task(Of TResult)
public Task<TResult> ExecuteAsync<TResult> (
    Func<Task<TResult>> taskFunc,
    CancellationToken cancellationToken
)
public:
generic<typename TResult>
Task<TResult>^ ExecuteAsync (
    Func<Task<TResult>^>^ taskFunc, 
    CancellationToken cancellationToken
)

Parameters

  • taskFunc
    A function that returns a started task (also known as "hot" task).
  • cancellationToken
    The token used to cancel the retry operation. This token does not cancel the execution of the asynchronous task.

Return Value

Returns a task that will run to completion if the original task completes successfully (either the first time or after retrying transient failures). If the task fails with a non-transient error or the retry limit is reached, the returned task will transition to a faulted state and the exception must be observed.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Target Platforms

See Also

Reference

RetryPolicy Class
RetryPolicy Members
Microsoft.WindowsAzure.Common.TransientFaultHandling Namespace