Пример #1
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Call ctor with string.Empty");

        try
        {
            TimeoutException ex = new TimeoutException(string.Empty);
            if (null == ex)
            {
                TestLibrary.TestFramework.LogError("002.1", "Calling ctor will string.Empty returns null reference");
                retVal = false;
            }

            string message = ex.Message;
            // using default message
            if (message == null)
            {
                TestLibrary.TestFramework.LogError("002.2", "Calling ctor will string.Empty returns null message");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Пример #2
0
        private JsRuntimeException ConvertTimeoutExceptionToJsRuntimeException(
            TimeoutException jsTimeoutException)
        {
            var jsRuntimeException = new JsRuntimeException(Strings.Runtime_ExecutionTimeout,
                                                            ENGINE_NAME, ENGINE_VERSION)
            {
                Category = "TimeoutError",
                Source   = jsTimeoutException.Source,
                HelpLink = jsTimeoutException.HelpLink
            };

            return(jsRuntimeException);
        }
        internal static StorageException GenerateTimeoutException(RequestResult res, Exception inner)
        {
            if (res != null)
            {
                res.HttpStatusCode = 408; // RequestTimeout
            }

            TimeoutException timeoutEx = new TimeoutException(SR.TimeoutExceptionMessage, inner);
            return new StorageException(res, timeoutEx.Message, timeoutEx)
            {
                IsRetryable = false
            };
        }
        public void AddSerializedDataDoesNotIncludeNullNestedTypeInExceptionData()
        {
            var key   = Guid.NewGuid().ToString();
            var value = Model.Ignoring <Company>(x => x.Owner).Create <Company>();

            var sut = new TimeoutException();

            sut.AddSerializedData(key, value);

            var expected = sut.Data[key] as string;

            expected.Should().NotContain(typeof(SerializeFailure).FullName);
        }
        private JsRuntimeException ConvertTimeoutExceptionToJsRuntimeException(
            TimeoutException jsTimeoutException)
        {
            var jsRuntimeException = new JsRuntimeException(Strings.Runtime_ExecutionTimeout,
                                                            EngineName, EngineVersion)
            {
                Category = "TimeoutError",
                Source   = jsTimeoutException.Source,
                HelpLink = jsTimeoutException.HelpLink
            };

            return(jsRuntimeException);
        }
Пример #6
0
        private static WrapperTimeoutException WrapTimeoutException(TimeoutException originalTimeoutException)
        {
            string message     = CoreStrings.Runtime_ScriptTimeoutExceeded;
            string description = message;

            var wrapperTimeoutException = new WrapperTimeoutException(message, EngineName, EngineVersion,
                                                                      originalTimeoutException)
            {
                Description = description
            };

            return(wrapperTimeoutException);
        }
Пример #7
0
            public void Unwraps_DbUpdateException()
            {
                var innerException = new TimeoutException();

                Assert.True(
                    DbExecutionStrategy.UnwrapAndHandleException(
                        new DbUpdateException("", innerException),
                        ex =>
                {
                    Assert.Same(innerException, ex);
                    return(true);
                }));
            }
        public async Task LinearRetryRetriesOnNonBatchException()
        {
            TimeSpan    interval    = TimeSpan.FromSeconds(5);
            const int   maxRetries  = 10;
            LinearRetry linearRetry = new LinearRetry(interval, maxRetries);

            TimeoutException timeoutException = new TimeoutException();

            RetryDecision retryDecision = await linearRetry.ShouldRetryAsync(timeoutException, new OperationContext());

            Assert.Equal(interval, retryDecision.RetryDelay);
            Assert.True(retryDecision.ShouldRetry);
        }
            public void Unwraps_Nested_exceptions()
            {
                var innerException = new TimeoutException("", new EntityException("", new DbUpdateException("", new UpdateException(""))));

                Assert.True(
                    ExecutionStrategyBase.UnwrapAndHandleException(
                        new EntityException("", new DbUpdateException("", new UpdateException("", innerException))),
                        ex =>
                {
                    Assert.Same(innerException, ex);
                    return(true);
                }));
            }
        internal static StorageException GenerateTimeoutException(RequestResult res, Exception inner)
        {
            if (res != null)
            {
                res.HttpStatusCode = 408;
            }
            TimeoutException ex = new TimeoutException("The client could not finish the operation within specified timeout.", inner);

            return(new StorageException(res, ex.Message, ex)
            {
                IsRetryable = false
            });
        }
        public void HasSerializedDataReturnsWhetherExceptionContainsData()
        {
            var key         = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
            var value       = Guid.NewGuid().ToString();
            var keyNotFound = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);

            var sut = new TimeoutException();

            sut.Data.Add(key, value);

            sut.HasSerializedData(key).Should().BeTrue();
            sut.HasSerializedData(keyNotFound).Should().BeFalse();
        }
        /// <summary>
        ///     Marks a transaction as Failed and provides a <see cref="TimeoutException" /> as the source of failure.
        ///     This also completes the transaction and releases any waiting threads.
        /// </summary>
        /// <param name="transaction">The transaction.</param>
        /// <param name="message">The message.</param>
        public static void TimedOut(this DeviceTransaction transaction, string message = null)
        {
            var exception     = new TimeoutException(message ?? "Timeout");
            var type          = transaction.GetType();
            var onErrorMethod = type.GetMethod("OnError", BindingFlags.Instance | BindingFlags.NonPublic);

            onErrorMethod.Invoke(
                transaction,
                BindingFlags.NonPublic | BindingFlags.Instance,
                Type.DefaultBinder,
                new object[] { exception },
                null);
        }
Пример #13
0
 /// <summary>
 /// Called when the operation times out.
 /// </summary>
 private void OnTimeout(object state)
 {
     try
     {
         Exception = new TimeoutException();
         m_cts?.Cancel();
         OperationCompleted();
     }
     catch (Exception e)
     {
         Utils.LogTrace(e, "Unexpected error handling timeout for ChannelAsyncResult operation.");
     }
 }
Пример #14
0
        static StaticData()
        {
            // Exception created but is not thrown
            TestCreatedException = new SystemException("System Test Exception");

            // Traditional created and throw exception
            try
            {
                throw new RankException("Rank Test");
            }
            catch (RankException e)
            {
                TestThrowException = e;
            }

            // Exception containing inner exceptions
            try
            {
                try
                {
                    try
                    {
                        throw new TypeAccessException("Test Type Exception");
                    }
                    catch (TypeAccessException exp1)
                    {
                        throw new DivideByZeroException("Divide By Zero Test", exp1);
                    }
                }
                catch (DivideByZeroException exp2)
                {
                    throw new ArithmeticException("Inner Exception Test", exp2);
                }
            }
            catch (ArithmeticException exp3)
            {
                TestInnerException = exp3;
            }

            // Exception with a defined stack trace
            var callClass = new TestNamespace.ClassAlpha();

            try
            {
                callClass.ThrowException();
            }
            catch (TimeoutException exp)
            {
                TestCallStackException = exp;
            }
        }
Пример #15
0
        private IConnection TryConnect(Uri remoteUri, string resolvedAddress, BackoffTimeoutHelper backoffHelper)
        {
            bool flag = backoffHelper.IsExpired();
            int  dwFlagsAndAttributes = 0x40000000;

            if (this.includeSecurityIdentity)
            {
                dwFlagsAndAttributes |= 0x110000;
            }
            PipeHandle handle    = UnsafeNativeMethods.CreateFile(resolvedAddress, -1073741824, 0, IntPtr.Zero, 3, dwFlagsAndAttributes, IntPtr.Zero);
            int        errorCode = Marshal.GetLastWin32Error();

            if (handle.IsInvalid)
            {
                handle.SetHandleAsInvalid();
            }
            else
            {
                int mode = 2;
                if (UnsafeNativeMethods.SetNamedPipeHandleState(handle, ref mode, IntPtr.Zero, IntPtr.Zero) == 0)
                {
                    errorCode = Marshal.GetLastWin32Error();
                    handle.Close();
                    PipeException exception = new PipeException(System.ServiceModel.SR.GetString("PipeModeChangeFailed", new object[] { PipeError.GetErrorString(errorCode) }), errorCode);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.CreateConnectFailedException(remoteUri, exception));
                }
                return(new PipeConnection(handle, this.bufferSize, false, true));
            }
            if ((errorCode == 2) || (errorCode == 0xe7))
            {
                TimeoutException exception3;
                if (!flag)
                {
                    return(null);
                }
                Exception exception2  = new PipeException(System.ServiceModel.SR.GetString("PipeConnectAddressFailed", new object[] { resolvedAddress, PipeError.GetErrorString(errorCode) }), errorCode);
                string    absoluteUri = remoteUri.AbsoluteUri;
                if (errorCode == 0xe7)
                {
                    exception3 = new TimeoutException(System.ServiceModel.SR.GetString("PipeConnectTimedOutServerTooBusy", new object[] { absoluteUri, backoffHelper.OriginalTimeout }), exception2);
                }
                else
                {
                    exception3 = new TimeoutException(System.ServiceModel.SR.GetString("PipeConnectTimedOut", new object[] { absoluteUri, backoffHelper.OriginalTimeout }), exception2);
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(exception3);
            }
            PipeException innerException = new PipeException(System.ServiceModel.SR.GetString("PipeConnectAddressFailed", new object[] { resolvedAddress, PipeError.GetErrorString(errorCode) }), errorCode);

            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.CreateConnectFailedException(remoteUri, innerException));
        }
Пример #16
0
        internal static Exception ConvertAndTraceException(Exception ex, TimeSpan timeout, string operation)
        {
            if (ex is ObjectDisposedException objectDisposedException)
            {
                var communicationObjectAbortedException = new CommunicationObjectAbortedException(ex.Message, ex);
                Fx.Exception.AsWarning(communicationObjectAbortedException);
                return(communicationObjectAbortedException);
            }

            if (ex is AggregateException aggregationException)
            {
                Exception exception = Fx.Exception.AsError <OperationCanceledException>(aggregationException);
                if (exception is OperationCanceledException operationCanceledException)
                {
                    TimeoutException timeoutException = GetTimeoutException(exception, timeout, operation);
                    Fx.Exception.AsWarning(timeoutException);
                    return(timeoutException);
                }
                else
                {
                    Exception communicationException = ConvertAggregateExceptionToCommunicationException(aggregationException);
                    if (communicationException is CommunicationObjectAbortedException)
                    {
                        Fx.Exception.AsWarning(communicationException);
                        return(communicationException);
                    }
                    else
                    {
                        return(Fx.Exception.AsError(communicationException));
                    }
                }
            }

            if (ex is WebSocketException webSocketException)
            {
                switch (webSocketException.WebSocketErrorCode)
                {
                case WebSocketError.InvalidMessageType:
                case WebSocketError.UnsupportedProtocol:
                case WebSocketError.UnsupportedVersion:
                    ex = new ProtocolException(ex.Message, ex);
                    break;

                default:
                    ex = new CommunicationException(ex.Message, ex);
                    break;
                }
            }

            return(Fx.Exception.AsError(ex));
        }
Пример #17
0
        public static ErrorCategory GetErrorCategoryForException(Exception exception)
        {
            var errorCategory = ErrorCategory.NotSpecified;

            if (exception is ArgumentException)
            {
                errorCategory = ErrorCategory.InvalidArgument;
            }
            else if (exception is InvalidOperationException ||
                     exception is FabricException ||
                     exception is FabricValidationException)
            {
                errorCategory = ErrorCategory.InvalidOperation;
            }
            else if (exception is InvalidDataException ||
                     exception is InvalidCastException)
            {
                errorCategory = ErrorCategory.InvalidData;
            }
            else if (exception is XmlSchemaValidationException ||
                     exception is XmlException)
            {
                errorCategory = ErrorCategory.ParserError;
            }
            else if (exception is TimeoutException)
            {
                errorCategory = ErrorCategory.OperationTimeout;
                exception     = new TimeoutException(StringResources.Error_ClusterConnectionTimeout);
            }
            else if (exception is OperationCanceledException)
            {
                errorCategory = ErrorCategory.OperationStopped;
            }
            else if (exception is UnauthorizedAccessException ||
                     exception is SecurityException)
            {
                errorCategory = ErrorCategory.SecurityError;
            }
            else if (exception is NullReferenceException ||
                     exception is FileNotFoundException ||
                     exception is DirectoryNotFoundException)
            {
                errorCategory = ErrorCategory.ResourceUnavailable;
            }
            else if (exception is FabricTransientException)
            {
                errorCategory = ErrorCategory.ResourceUnavailable;
            }

            return(errorCategory);
        }
Пример #18
0
        private static string BuildErrorMessage(Exception exception)
        {
            List <string> result = new List <string>();

            //result.Add("Es ist ein Fehler aufgetreten!");

            if (exception.GetType() == typeof(InvalidPluginExecutionException))
            {
                InvalidPluginExecutionException ex = (InvalidPluginExecutionException)exception;
                result.Add(ex.Message);
            }
            else if (exception.GetType() == typeof(FaultException <OrganizationServiceFault>))
            {
                FaultException <OrganizationServiceFault> ex = (FaultException <OrganizationServiceFault>)exception;
                result.Add(ex.Message);
            }
            else if (exception.GetType() == typeof(TimeoutException))
            {
                TimeoutException ex = (TimeoutException)exception;
                result.Add(string.Format("Message: {0}", ex.Message));
                result.Add(string.Format("Stack Trace: {0}", ex.StackTrace));
                result.Add(string.Format("Inner Fault: {0}",
                                         null == ex.InnerException.Message ? "Has Inner Fault" : "No Inner Fault"));
            }
            else
            {
                Exception ex = exception;
                result.Add(string.Format(ex.Message));

                // Display the details of the inner exception.
                if (ex.InnerException != null)
                {
                    result.Add(string.Format(ex.InnerException.Message));

                    FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> fe = ex.InnerException
                                                                                     as FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault>;
                    if (fe != null)
                    {
                        result.Add(string.Format("Timestamp: {0}", fe.Detail.Timestamp));
                        result.Add(string.Format("Code: {0}", fe.Detail.ErrorCode));
                        result.Add(string.Format("Message: {0}", fe.Detail.Message));
                        result.Add(string.Format("Trace: {0}", fe.Detail.TraceText));
                        result.Add(string.Format("Inner Fault: {0}",
                                                 null == fe.Detail.InnerFault ? "Has Inner Fault" : "No Inner Fault"));
                    } //if
                }     //if
            }         //if

            return(string.Join(Environment.NewLine, result.ToArray()));
        }//BuildErrorMessage
Пример #19
0
        public void LogErrorWithWritesLogWithExceptionAndNullContextData()
        {
            var exception = new TimeoutException();

            _logger.LogErrorWithContext(exception, null);

            var actual = _logger.Last;

            actual.LogLevel.Should().Be(LogLevel.Error);
            actual.EventId.Id.Should().Be(0);
            actual.Message.Should().BeNull();
            actual.Exception.Should().Be(exception);
            actual.Exception.Data.Should().BeEmpty();
        }
        public static ReliableHttpException Create(string message, Exception exception)
        {
            ReliableHttpException ex;
            if (exception.Message.Contains("The request was aborted"))
            {
                ex = new TimeoutException(message, exception);
            }
            else
            {
                ex = new ReliableHttpException(message, exception);
            }

            return ex;
        }
Пример #21
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Connection"/> class.
        /// </summary>
        /// <param name="ipEndPoint">The remote IP endpoint of the connection.</param>
        /// <param name="options">The optional options for the connection.</param>
        /// <param name="tcpClient">The optional TcpClient instance to use.</param>
        public Connection(IPEndPoint ipEndPoint, ConnectionOptions options = null, ITcpClient tcpClient = null)
        {
            Id = Guid.NewGuid();

            IPEndPoint = ipEndPoint;
            Options    = options ?? new ConnectionOptions();

            TcpClient = tcpClient ?? new TcpClientAdapter(new TcpClient());
            TcpClient.Client.ReceiveBufferSize = Options.ReadBufferSize;
            TcpClient.Client.SendBufferSize    = Options.WriteBufferSize;

            if (Options.InactivityTimeout > 0)
            {
                InactivityTimer = new SystemTimer()
                {
                    Enabled   = false,
                    AutoReset = false,
                    Interval  = Options.InactivityTimeout,
                };

                InactivityTimer.Elapsed += (sender, e) =>
                {
                    var ex = new TimeoutException($"Inactivity timeout of {Options.InactivityTimeout} milliseconds was reached");
                    Disconnect(ex.Message, ex);
                };
            }

            WatchdogTimer = new SystemTimer()
            {
                Enabled   = false,
                AutoReset = true,
                Interval  = 250,
            };

            WatchdogTimer.Elapsed += (sender, e) =>
            {
                if (TcpClient == null || !TcpClient.Connected)
                {
                    Disconnect($"The server connection was closed unexpectedly");
                }
            };

            if (TcpClient.Connected)
            {
                State = ConnectionState.Connected;
                InactivityTimer?.Start();
                WatchdogTimer.Start();
                Stream = TcpClient.GetStream();
            }
        }
        private static void ReadCallback(object state)
        {
            Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader serverSessionPreambleConnectionReader = (Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader)state;
            bool flag = false;

            try
            {
                try
                {
                    serverSessionPreambleConnectionReader.GetReadResult();
                    serverSessionPreambleConnectionReader.ContinueReading();
                    flag = true;
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
                    {
                        Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(communicationException, TraceEventType.Information);
                    }
                }
                catch (TimeoutException timeoutException1)
                {
                    TimeoutException timeoutException = timeoutException1;
                    if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
                    {
                        Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(timeoutException, TraceEventType.Information);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    if (!ExceptionHandler.HandleTransportExceptionHelper(exception))
                    {
                        throw;
                    }
                }
            }
            finally
            {
                if (!flag)
                {
                    serverSessionPreambleConnectionReader.Abort();
                }
            }
        }
Пример #23
0
    private static T AsyncToSyncWithTimeout <T>(
        Func <AsyncCallback, object, IAsyncResult> begin,
        Func <IAsyncResult, T> end,
        int millisecondsTimeout)
    {
        var iar = begin(null, null);

        if (!iar.AsyncWaitHandle.WaitOne(millisecondsTimeout))
        {
            var ex = new TimeoutException();
            throw new WebException(ex.Message, ex, WebExceptionStatus.Timeout, null);
        }
        return(end(iar));
    }
Пример #24
0
        void timeoutTimer_Tick(object sender, EventArgs e)
        {
            string url = String.Empty;

            try
            {
                url = Browser.Url.ToString();
            }
            catch (Exception)
            {
            }
            exception = new TimeoutException(url);
            this.Close();
        }
        public void AddSerializedDataAppendsValueTypeValuesTest(object value)
        {
            var key = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);

            var sut = new TimeoutException();

            sut.AddSerializedData(key, value);

            var actual = sut.Data[key];

            _output.WriteLine("Stored data is: {0}", actual);

            actual.Should().Be(value);
        }
Пример #26
0
        public async Task CloseAsync(bool aborting, CancellationToken token)
        {
            if (closed)
            {
                return;
            }

            IList <TransportManager> transportManagersCopy;

            using (await tableLock.TakeLockAsync())
            {
                if (closed)
                {
                    return;
                }

                closed = true;

                transportManagersCopy = new List <TransportManager>(transportManagers);
                transportManagers.Clear();

                TimeoutException timeoutException = null;
                foreach (TransportManager transportManager in transportManagersCopy)
                {
                    try
                    {
                        if (!aborting && timeoutException == null)
                        {
                            await transportManager.CloseAsync(listener, token);
                        }
                        else
                        {
                            transportManager.Abort(listener);
                        }
                    }
                    catch (TimeoutException ex)
                    {
                        timeoutException = ex;
                        transportManager.Abort(listener);
                    }
                }

                if (timeoutException != null)
                {
                    // TODO: Find a way to propagate the timeout value
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException(SR.Format(SR.TimeoutOnClose, TimeSpan.Zero), timeoutException));
                }
            }
        }
        private void OnAsyncReadComplete(object state)
        {
            bool flag = false;

            try
            {
                try
                {
                    this.HandleReadComplete();
                    this.ReadAndDispatch();
                    flag = true;
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
                    {
                        Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(communicationException, TraceEventType.Information);
                    }
                }
                catch (TimeoutException timeoutException1)
                {
                    TimeoutException timeoutException = timeoutException1;
                    if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
                    {
                        Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(timeoutException, TraceEventType.Information);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    if (!ExceptionHandler.HandleTransportExceptionHelper(exception))
                    {
                        throw;
                    }
                }
            }
            finally
            {
                if (!flag)
                {
                    base.Abort();
                }
            }
        }
Пример #28
0
        public void Close(bool aborting, TimeSpan timeout)
        {
            if (this.closed)
            {
                return;
            }

            IList <TransportManager> transportManagersCopy;

            lock (this.tableLock)
            {
                if (this.closed)
                {
                    return;
                }

                this.closed = true;

                transportManagersCopy = new List <TransportManager>(this.transportManagers);
                this.transportManagers.Clear();

                TimeoutHelper    timeoutHelper    = new TimeoutHelper(timeout);
                TimeoutException timeoutException = null;
                foreach (TransportManager transportManager in transportManagersCopy)
                {
                    try
                    {
                        if (!aborting && timeoutException == null)
                        {
                            transportManager.Close(listener, timeoutHelper.RemainingTime());
                        }
                        else
                        {
                            transportManager.Abort(listener);
                        }
                    }
                    catch (TimeoutException ex)
                    {
                        timeoutException = ex;
                        transportManager.Abort(listener);
                    }
                }

                if (timeoutException != null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new TimeoutException(SR.GetString(SR.TimeoutOnClose, timeout), timeoutException));
                }
            }
        }
Пример #29
0
 internal void CreateTimeoutTimer(HttpWebRequest request)
 {
     if (Request.ConnectionTimeout > 0)
     {
         timer = new Timer(s =>
         {
             timer.Dispose();
             if (IsPending && !IsConnected)
             {
                 Exception = new TimeoutException("The connection timed out.");
                 Abort();
             }
         }, null, Request.ConnectionTimeout * 1000, Timeout.Infinite);
     }
 }
Пример #30
0
        private void CheckTimeout(uint current)
        {
            if (_lastRecvTime == 0)
            {
                _lastRecvTime = current;
            }

            if (current - _lastRecvTime <= _recvTimeoutSec * 1000)
            {
                return;
            }
            var ex = new TimeoutException("socket recv timeout");

            PushError(ex);
        }
Пример #31
0
        public void LogCriticalWithWritesLogWithEventIdExceptionAndNullContextData()
        {
            var eventId   = new EventId(Environment.TickCount);
            var exception = new TimeoutException();

            _logger.LogCriticalWithContext(eventId, exception, null);

            var actual = _logger.Last;

            actual.LogLevel.Should().Be(LogLevel.Critical);
            actual.EventId.Id.Should().Be(eventId.Id);
            actual.Message.Should().BeNull();
            actual.Exception.Should().Be(exception);
            actual.Exception.Data.Should().BeEmpty();
        }
Пример #32
0
        public void LogErrorWithWritesLogWithExceptionAndContextData()
        {
            var exception   = new TimeoutException();
            var contextData = Guid.NewGuid().ToString();

            _logger.LogErrorWithContext(exception, contextData);

            var actual = _logger.Last;

            actual.LogLevel.Should().Be(LogLevel.Error);
            actual.EventId.Id.Should().Be(0);
            actual.Message.Should().BeNull();
            actual.Exception.Should().Be(exception);
            actual.Exception.Data["ContextData"].ToString().Should().Contain(contextData);
        }
Пример #33
0
        public static ReliableHttpException Create(Exception exception)
        {
            if (exception is ReliableHttpException)
            {
                return (ReliableHttpException) exception;
            }

            ReliableHttpException ex;
            if (exception.Message.Contains("The request was aborted"))
            {
                ex = new TimeoutException(exception);
            }
            else
            {
                ex = new ReliableHttpException(exception);
            }

            return ex;
        }
Пример #34
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call ctor with null");

        try
        {
            TimeoutException ex = new TimeoutException(null, null);
            if (null == ex)
            {
                TestLibrary.TestFramework.LogError("001.1", "Calling ctor will null returns null reference");
                retVal = false;
            }

            string message = ex.Message;
            // using default message
            if (message == null)
            {
                TestLibrary.TestFramework.LogError("001.2", "Calling ctor will null returns null message");
                retVal = false;
            }

            Exception innerException = ex.InnerException;
            // using default message
            if (innerException != null)
            {
                TestLibrary.TestFramework.LogError("001.3", "Calling ctor will null returns not null innerException");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Пример #35
0
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call ctor to create a new instance");

        try
        {
            TimeoutException ex = new TimeoutException();
            if (ex == null)
            {
                TestLibrary.TestFramework.LogError("001.1", "Calling ctor returns null reference");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Пример #36
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Call ctor with rand message");

        try
        {
            string expected = TestLibrary.Generator.GetString(-55, false, 1, 256);
            TimeoutException ex = new TimeoutException(expected);
            if (null == ex)
            {
                TestLibrary.TestFramework.LogError("003.1", "Calling ctor will rand message returns null reference");
                retVal = false;
            }

            string message = ex.Message;
            // using default message
            if (message != expected)
            {
                TestLibrary.TestFramework.LogError("003.2", "Calling ctor will rand message returns null message");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLES] message = " + message + ", expected = " + expected);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Пример #37
0
        unsafe void WaitForSyncWrite(TimeSpan timeout, bool traceExceptionsAsErrors, ref object holder)
        {
            if (this.isWriteOutstanding)
            {
                if (!this.writeOverlapped.WaitForSyncOperation(timeout, ref holder))
                {
                    Abort(SR.GetString(SR.PipeConnectionAbortedWriteTimedOut, this.writeTimeout), TransferOperation.Write);

                    Exception timeoutException = new TimeoutException(SR.GetString(SR.PipeWriteTimedOut, timeout));
                    TraceEventType traceEventType = TraceEventType.Information;
                    if (traceExceptionsAsErrors)
                    {
                        traceEventType = TraceEventType.Error;
                    }

                    // This intentionally doesn't reset isWriteOutstanding, because technically it still is, and we need to not free the buffer.
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelper(timeoutException, traceEventType);
                }
                else
                {
                    this.isWriteOutstanding = false;
                }
            }
        }
Пример #38
0
 static internal TimeoutException TimeoutException(string error)
 {
     TimeoutException e = new TimeoutException(error);
     return e;
 }
Пример #39
0
 /// <summary>
 /// Creates a <see cref="TimeoutException"/>.
 /// </summary>
 /// <param name="agent">Agent address</param>
 /// <param name="timeout">Timeout</param>
 /// <returns></returns>
 public static TimeoutException Create(IPAddress agent, int timeout)
 {
     if (agent == null)
     {
         throw new ArgumentNullException("agent");
     }
     
     var ex = new TimeoutException { Agent = agent, Timeout = timeout };
     return ex;
 }
 protected override TimeoutException CreateNewConnectionTimeoutException(TimeSpan timeout, TimeoutException innerException)
 {
     return new TimeoutException(SR.GetString(SR.RequestTimedOutEstablishingTransportSession,
             timeout, channel.Via.AbsoluteUri), innerException);
 }
 static void HandleEndWait(object state, TimeoutException e)
 {
     GetResponseAsyncResult thisPtr = (GetResponseAsyncResult)state;
     thisPtr.Complete(false, e);
 }
 public void Unwraps_Nested_exceptions()
 {
     var innerException = new TimeoutException("", new EntityException("", new DbUpdateException("", new UpdateException(""))));
     Assert.True(
         DbExecutionStrategy.UnwrapAndHandleException(
             new EntityException("", new DbUpdateException("", new UpdateException("", innerException))),
             ex =>
                 {
                     Assert.Same(innerException, ex);
                     return true;
                 }));
 }
        static Exception ConvertTransferException(SocketException socketException, TimeSpan timeout, Exception originalException,
            TransferOperation transferOperation, bool aborted, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation,
            SocketConnection socketConnection, TimeSpan remainingTime)
        {
            if (socketException.ErrorCode == UnsafeNativeMethods.ERROR_INVALID_HANDLE)
            {
                return new CommunicationObjectAbortedException(socketException.Message, socketException);
            }

            if (timeoutErrorString != null)
            {
                return ConvertTimeoutErrorException(originalException, transferOperation, timeoutErrorString, timeoutErrorTransferOperation);
            }

            TraceEventType exceptionEventType = socketConnection == null ? TraceEventType.Error : socketConnection.ExceptionEventType;

            // 10053 can occur due to our timeout sockopt firing, so map to TimeoutException in that case
            if (socketException.ErrorCode == UnsafeNativeMethods.WSAECONNABORTED &&
                remainingTime <= TimeSpan.Zero)
            {
                TimeoutException timeoutException = new TimeoutException(SR.GetString(SR.TcpConnectionTimedOut, timeout), originalException);
                if (TD.TcpConnectionTimedOutIsEnabled())
                {
                    if (socketConnection != null)
                    {
                        int socketid = (socketConnection != null && socketConnection.socket != null) ? socketConnection.socket.GetHashCode() : -1;
                        TD.TcpConnectionTimedOut(socketid, socketConnection.RemoteEndpointAddress);
                    }
                }
                if (DiagnosticUtility.ShouldTrace(exceptionEventType))
                {
                    TraceUtility.TraceEvent(exceptionEventType, TraceCode.TcpConnectionTimedOut, GetEndpointString(SR.TcpConnectionTimedOut, timeout, null, socketConnection), timeoutException, null);
                }
                return timeoutException;
            }

            if (socketException.ErrorCode == UnsafeNativeMethods.WSAENETRESET ||
                socketException.ErrorCode == UnsafeNativeMethods.WSAECONNABORTED ||
                socketException.ErrorCode == UnsafeNativeMethods.WSAECONNRESET)
            {
                if (aborted)
                {
                    return new CommunicationObjectAbortedException(SR.GetString(SR.TcpLocalConnectionAborted), originalException);
                }
                else
                {
                    CommunicationException communicationException = new CommunicationException(SR.GetString(SR.TcpConnectionResetError, timeout), originalException);
                    if (TD.TcpConnectionResetErrorIsEnabled())
                    {
                        if (socketConnection != null)
                        {
                            int socketId = (socketConnection.socket != null) ? socketConnection.socket.GetHashCode() : -1;
                            TD.TcpConnectionResetError(socketId, socketConnection.RemoteEndpointAddress);
                        }
                    }
                    if (DiagnosticUtility.ShouldTrace(exceptionEventType))
                    {
                        TraceUtility.TraceEvent(exceptionEventType, TraceCode.TcpConnectionResetError, GetEndpointString(SR.TcpConnectionResetError, timeout, null, socketConnection), communicationException, null);
                    }
                    return communicationException;
                }
            }
            else if (socketException.ErrorCode == UnsafeNativeMethods.WSAETIMEDOUT)
            {
                TimeoutException timeoutException = new TimeoutException(SR.GetString(SR.TcpConnectionTimedOut, timeout), originalException);
                if (DiagnosticUtility.ShouldTrace(exceptionEventType))
                {
                    TraceUtility.TraceEvent(exceptionEventType, TraceCode.TcpConnectionTimedOut, GetEndpointString(SR.TcpConnectionTimedOut, timeout, null, socketConnection), timeoutException, null);
                }
                return timeoutException;
            }
            else
            {
                if (aborted)
                {
                    return new CommunicationObjectAbortedException(SR.GetString(SR.TcpTransferError, socketException.ErrorCode, socketException.Message), originalException);
                }
                else
                {
                    CommunicationException communicationException = new CommunicationException(SR.GetString(SR.TcpTransferError, socketException.ErrorCode, socketException.Message), originalException);
                    if (DiagnosticUtility.ShouldTrace(exceptionEventType))
                    {
                        TraceUtility.TraceEvent(exceptionEventType, TraceCode.TcpTransferError, GetEndpointString(SR.TcpTransferError, TimeSpan.MinValue, socketException, socketConnection), communicationException, null);
                    }
                    return communicationException;
                }
            }
        }
Пример #44
0
        internal override void Timeout(InternalTransaction tx)
        {
            if (DiagnosticTrace.Warning)
            {
                TransactionTimeoutTraceRecord.Trace(SR.TraceSourceLtm,
                    tx.TransactionTraceId
                    );
            }

            TimeoutException e = new TimeoutException(SR.TraceTransactionTimeout);
            Rollback(tx, e);
        }
Пример #45
0
        internal override void Timeout(InternalTransaction tx)
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
            if (etwLog.IsEnabled())
            {
                etwLog.TransactionTimeout(tx.TransactionTraceId);
            }

            TimeoutException e = new TimeoutException(SR.TraceTransactionTimeout);
            Rollback(tx, e);
        }
            static void OnWaitComplete(object state, TimeoutException timeoutException)
            {
                BindReclaimedLockAsyncResult thisPtr = (BindReclaimedLockAsyncResult)state;

                Exception completionException = null;
                try
                {
                    if (timeoutException != null)
                    {
                        thisPtr.context.InstanceHandle.CancelReclaim(new TimeoutException(SRCore.TimedOutWaitingForLockResolution));
                    }
                    thisPtr.context.ConcludeBindReclaimedLockHelper();
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    completionException = exception;
                }
                thisPtr.Complete(false, completionException);
            }
Пример #47
0
 static void OnHostTransaction(object state, TimeoutException timeoutException)
 {
     AcquireContextAsyncResult pThis = (AcquireContextAsyncResult)state;
     Exception exception = timeoutException;
     bool completeSelf = exception != null;
     if (!completeSelf)
     {
         try
         {
             if (pThis.DoAfterTransaction())
             {
                 completeSelf = true;
             }
         }
         catch (Exception e)
         {
             if (Fx.IsFatal(e))
             {
                 throw;
             }
             exception = e;
             completeSelf = true;
         }
     }
     if (completeSelf)
     {
         if (exception != null)
         {
             pThis.handle.FinishOperation();
         }
         pThis.Complete(false, exception);
     }
 }
Пример #48
0
        IConnection TryConnect(Uri remoteUri, string resolvedAddress, BackoffTimeoutHelper backoffHelper)
        {
            const int access = UnsafeNativeMethods.GENERIC_READ | UnsafeNativeMethods.GENERIC_WRITE;
            bool lastAttempt = backoffHelper.IsExpired();

            int flags = UnsafeNativeMethods.FILE_FLAG_OVERLAPPED;

            // By default Windows named pipe connection is created with impersonation, but we want
            // to create it with anonymous and let WCF take care of impersonation/identification.
            flags |= UnsafeNativeMethods.SECURITY_QOS_PRESENT | UnsafeNativeMethods.SECURITY_ANONYMOUS;

            PipeHandle pipeHandle = UnsafeNativeMethods.CreateFile(resolvedAddress, access, 0, IntPtr.Zero,
                UnsafeNativeMethods.OPEN_EXISTING, flags, IntPtr.Zero);
            int error = Marshal.GetLastWin32Error();
            if (pipeHandle.IsInvalid)
            {
                pipeHandle.SetHandleAsInvalid();
            }
            else
            {
                int mode = UnsafeNativeMethods.PIPE_READMODE_MESSAGE;
                if (UnsafeNativeMethods.SetNamedPipeHandleState(pipeHandle, ref mode, IntPtr.Zero, IntPtr.Zero) == 0)
                {
                    error = Marshal.GetLastWin32Error();
                    pipeHandle.Close();
                    PipeException innerException = new PipeException(SR.GetString(SR.PipeModeChangeFailed,
                        PipeError.GetErrorString(error)), error);
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                        CreateConnectFailedException(remoteUri, innerException));
                }
                return new PipeConnection(pipeHandle, bufferSize, false, true);
            }

            if (error == UnsafeNativeMethods.ERROR_FILE_NOT_FOUND || error == UnsafeNativeMethods.ERROR_PIPE_BUSY)
            {
                if (lastAttempt)
                {
                    Exception innerException = new PipeException(SR.GetString(SR.PipeConnectAddressFailed,
                        resolvedAddress, PipeError.GetErrorString(error)), error);

                    TimeoutException timeoutException;
                    string endpoint = remoteUri.AbsoluteUri;

                    if (error == UnsafeNativeMethods.ERROR_PIPE_BUSY)
                    {
                        timeoutException = new TimeoutException(SR.GetString(SR.PipeConnectTimedOutServerTooBusy,
                            endpoint, backoffHelper.OriginalTimeout), innerException);
                    }
                    else
                    {
                        timeoutException = new TimeoutException(SR.GetString(SR.PipeConnectTimedOut,
                            endpoint, backoffHelper.OriginalTimeout), innerException);
                    }

                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(timeoutException);
                }

                return null;
            }
            else
            {
                PipeException innerException = new PipeException(SR.GetString(SR.PipeConnectAddressFailed,
                    resolvedAddress, PipeError.GetErrorString(error)), error);
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    CreateConnectFailedException(remoteUri, innerException));
            }
        }
        void OnConnectionModeKnownCore(ConnectionModeReader modeReader, bool isCached)
        {
            lock (ThisLock)
            {
                if (isDisposed)
                    return;

                this.connectionReaders.Remove(modeReader);
            }

            bool closeReader = true;
            try
            {
                FramingMode framingMode;
                try
                {
                    framingMode = modeReader.GetConnectionMode();
                }
                catch (CommunicationException exception)
                {
                    TraceEventType eventType = modeReader.Connection.ExceptionEventType;
                    DiagnosticUtility.TraceHandledException(exception, eventType);
                    return;
                }
                catch (TimeoutException exception)
                {
                    if (!isCached)
                    {
                        exception = new TimeoutException(SR.GetString(SR.ChannelInitializationTimeout, this.channelInitializationTimeout), exception);
                        System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(exception);
                    }

                    if (TD.ChannelInitializationTimeoutIsEnabled())
                    {
                        TD.ChannelInitializationTimeout(SR.GetString(SR.ChannelInitializationTimeout, this.channelInitializationTimeout));
                    }

                    TraceEventType eventType = modeReader.Connection.ExceptionEventType;
                    DiagnosticUtility.TraceHandledException(exception, eventType);
                    return;
                }

                switch (framingMode)
                {
                    case FramingMode.Duplex:
                        OnDuplexConnection(modeReader.Connection, modeReader.ConnectionDequeuedCallback,
                            modeReader.StreamPosition, modeReader.BufferOffset, modeReader.BufferSize,
                            modeReader.GetRemainingTimeout());
                        break;

                    case FramingMode.Singleton:
                        OnSingletonConnection(modeReader.Connection, modeReader.ConnectionDequeuedCallback,
                            modeReader.StreamPosition, modeReader.BufferOffset, modeReader.BufferSize,
                            modeReader.GetRemainingTimeout());
                        break;

                    default:
                        {
                            Exception inner = new InvalidDataException(SR.GetString(
                                SR.FramingModeNotSupported, framingMode));
                            Exception exception = new ProtocolException(inner.Message, inner);
                            FramingEncodingString.AddFaultString(exception, FramingEncodingString.UnsupportedModeFault);
                            System.ServiceModel.Dispatcher.ErrorBehavior.ThrowAndCatch(exception);
                            return;
                        }
                }

                closeReader = false;
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                if (!ExceptionHandler.HandleTransportExceptionHelper(e))
                {
                    throw;
                }

                // containment -- the reader is aborted, no need for additional containment
            }
            finally
            {
                if (closeReader)
                {
                    modeReader.Dispose();
                }
            }
        }
        static void OnEnteredAsync(object state, TimeoutException exception)
        {
            EnterAsyncData data = (EnterAsyncData)state;
            ThreadNeutralSemaphore thisPtr = data.Semaphore;
            Exception exceptionToPropagate = exception;

            if (exception != null)
            {
                if (!thisPtr.RemoveWaiter(data.Waiter))
                {
                    // The timeout ----d with Exit and exit won.
                    // We've successfully entered.
                    exceptionToPropagate = null;
                }
            }

            Fx.Assert(!thisPtr.waiters.Contains(data.Waiter), "The waiter should have been removed already.");

            if (thisPtr.aborted)
            {
                exceptionToPropagate = thisPtr.CreateObjectAbortedException();
            }

            data.Callback(data.State, exceptionToPropagate);
        }
            static void HandleWaitForStoreEvents(object state, TimeoutException exception)
            {
                CloseAsyncResult thisPtr = (CloseAsyncResult)state;
                if (exception != null)
                {
                    thisPtr.Complete(false, exception);
                    return;
                }

                bool completeSelf = false;
                Exception completionException = null;

                try
                {
                    completeSelf = thisPtr.PerformClose();
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                    completionException = exception;
                    completeSelf = true;
                }

                if (completeSelf)
                {
                    thisPtr.Complete(false, completionException);
                }
            }
Пример #52
0
        private static Exception ConvertTransferException(SocketException socketException, TimeSpan timeout, Exception originalException,
            TransferOperation transferOperation, bool aborted, string timeoutErrorString, TransferOperation timeoutErrorTransferOperation,
            SocketConnection socketConnection, TimeSpan remainingTime)
        {
            if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.ERROR_INVALID_HANDLE)
            {
                return new CommunicationObjectAbortedException(socketException.Message, socketException);
            }

            if (timeoutErrorString != null)
            {
                return ConvertTimeoutErrorException(originalException, transferOperation, timeoutErrorString, timeoutErrorTransferOperation);
            }

            // 10053 can occur due to our timeout sockopt firing, so map to TimeoutException in that case
            if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAECONNABORTED &&
                remainingTime <= TimeSpan.Zero)
            {
                TimeoutException timeoutException = new TimeoutException(SR.Format(SR.TcpConnectionTimedOut, timeout), originalException);
                return timeoutException;
            }

            if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAENETRESET ||
                (int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAECONNABORTED ||
                (int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAECONNRESET)
            {
                if (aborted)
                {
                    return new CommunicationObjectAbortedException(SR.TcpLocalConnectionAborted, originalException);
                }
                else
                {
                    CommunicationException communicationException = new CommunicationException(SR.Format(SR.TcpConnectionResetError, timeout), originalException);
                    return communicationException;
                }
            }
            else if ((int)socketException.SocketErrorCode == UnsafeNativeMethods.WSAETIMEDOUT)
            {
                TimeoutException timeoutException = new TimeoutException(SR.Format(SR.TcpConnectionTimedOut, timeout), originalException);
                return timeoutException;
            }
            else
            {
                if (aborted)
                {
                    return new CommunicationObjectAbortedException(SR.Format(SR.TcpTransferError, (int)socketException.SocketErrorCode, socketException.Message), originalException);
                }
                else
                {
                    CommunicationException communicationException = new CommunicationException(SR.Format(SR.TcpTransferError, (int)socketException.SocketErrorCode, socketException.Message), originalException);
                    return communicationException;
                }
            }
        }
 public void Unwraps_UpdateException()
 {
     var innerException = new TimeoutException();
     Assert.True(
         DbExecutionStrategy.UnwrapAndHandleException(
             new UpdateException("", innerException),
             ex =>
                 {
                     Assert.Same(innerException, ex);
                     return true;
                 }));
 }
            static void OnBindReclaimed(object state, TimeoutException timeoutException)
            {
                ExecuteAsyncResult thisPtr = (ExecuteAsyncResult)state;

                bool completeSelf;
                Exception completionException = null;
                try
                {
                    thisPtr.BindReclaimed(timeoutException != null);
                    completeSelf = thisPtr.RunLoop();
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    completionException = exception;
                    completeSelf = true;
                }
                if (completeSelf)
                {
                    thisPtr.Complete(false, completionException);
                }
            }
 static void OnCommitWait(object state, TimeoutException exception)
 {
     ExecuteAsyncResult thisPtr = (ExecuteAsyncResult)state;
     thisPtr.Complete(false, exception ?? thisPtr.AfterCommitWait());
 }
            static void HandleWaitForInProgressLoad(object state, TimeoutException timeoutException)
            {
                LoadOrCreateAsyncResult thisPtr = (LoadOrCreateAsyncResult)state;
                if (timeoutException != null)
                {
                    thisPtr.Complete(false, timeoutException);
                    return;
                }

                bool completeSelf = false;
                Exception completionException = null;

                try
                {
                    if (thisPtr.LoadFromCache())
                    {
                        completeSelf = true;
                    }
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    completionException = exception;
                    completeSelf = true;
                }

                if (completeSelf)
                {
                    thisPtr.Complete(false, completionException);
                }
            }