private async ValueTask <Response> WaitForCompletionResponseAsync(bool async, TimeSpan?pollingInterval, CancellationToken cancellationToken)
        {
            // If _responseLock has the value, lockOrValue will contain that value, and no lock is acquired.
            // If _responseLock doesn't have the value, GetLockOrValueAsync will acquire the lock that will be released when lockOrValue is disposed
            using var lockOrValue = await _responseLock.GetLockOrValueAsync(async, cancellationToken).ConfigureAwait(false);

            if (lockOrValue.HasValue)
            {
                return(lockOrValue.Value);
            }

            var poller   = new OperationPoller(_fallbackStrategy);
            var response = async
                ? await poller.WaitForCompletionResponseAsync(this, pollingInterval, cancellationToken).ConfigureAwait(false)
                : poller.WaitForCompletionResponse(this, pollingInterval, cancellationToken);

            lockOrValue.SetValue(response);
            return(response);
        }
Esempio n. 2
0
        public static Response DefaultWaitForCompletionResponse(this Operation operation, TimeSpan pollingInterval, CancellationToken cancellationToken)
        {
            OperationPoller poller = new OperationPoller();

            return(poller.WaitForCompletionResponse(operation, pollingInterval, cancellationToken));
        }
        public virtual Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken)
        {
            OperationPoller poller = new OperationPoller(_fallbackStrategy);

            return(poller.WaitForCompletionResponse(UpdateStatus, () => HasCompleted, () => RawResponse, pollingInterval, cancellationToken));
        }
Esempio n. 4
0
        public static Response DefaultWaitForCompletionResponse(this Operation operation, CancellationToken cancellationToken)
        {
            OperationPoller poller = new OperationPoller();

            return(poller.WaitForCompletionResponse(operation, null, cancellationToken));
        }