Beispiel #1
0
        // Note for future maintainers:
        // In EndOperation<T> above, this method is called and sync-Wait()'d on, with runPostProcess set to false.
        // This means that, if 'runPostProcess' is ever false, this method must never hit an await point.
        // This restriction is irrelevant in future versions of the library that only have an async executor.
        private static async Task EndOperationAsync <T>(ExecutionState <T> executionState, bool runPostProcess)
        {
            Executor.FinishRequestAttempt(executionState);

            try
            {
                // If an operation has been canceled of timed out this should overwrite any exception
                Executor.CheckCancellation(executionState);
                Executor.CheckTimeout(executionState, true);

                // Success
                if (executionState.ExceptionRef == null)
                {
                    if (runPostProcess)
                    {
                        // Step 9 - This will not be called if an exception is raised during stream copying
                        await Executor.RunPostProcessAsync(executionState);
                    }
                    DisposeAndEnd <T>(executionState);
                    executionState.OnComplete();
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.LogWarning(executionState.OperationContext, SR.TracePostProcessError, ex.Message);
                executionState.ExceptionRef = ExecutorBase.TranslateExceptionBasedOnParseError(ex, executionState.Cmd.CurrentResult, executionState.Resp, executionState.Cmd.ParseError);
            }
            finally
            {
                try
                {
                    if (executionState.ReqStream != null)
                    {
                        executionState.ReqStream.Dispose();
                        executionState.ReqStream = null;
                    }

                    if (executionState.Resp != null)
                    {
                        executionState.Resp.Close();
                        executionState.Resp = null;
                    }
                }
                catch (Exception)
                {
                    // no op
                }
            }

            ConsiderRetry <T>(executionState);
        }