コード例 #1
0
ファイル: ExceptionViewModel.cs プロジェクト: henjuv/Mg2
        public ExceptionViewModel(Exception exception)
        {
            DisplayName = "An unhandled exception occurred";
            CloseCommand = new RelayCommand(TryClose);

            _exception = exception.Unwrap().ToAggregate();
        }
コード例 #2
0
        internal static bool IsRequestAborted(Exception exception)
        {
            exception = exception.Unwrap();

            // Support an alternative way to propagate aborted requests
            if (exception is OperationCanceledException)
            {
                return true;
            }

            // There is a race in StreamExtensions where if the endMethod in ReadAsync is called before
            // the Stream is disposed, but executes after, Stream.EndRead will be called on a disposed object.
            // Since we call HttpWebRequest.Abort in several places while potentially reading the stream,
            // and we don't want to lock around HttpWebRequest.Abort and Stream.EndRead, we just swallow the 
            // exception.
            // If the Stream is closed before the call to the endMethod, we expect an OperationCanceledException,
            // so this is a fairly rare race condition.
            if (exception is ObjectDisposedException)
            {
                return true;
            }

            var webException = exception as WebException;
            return (webException != null && webException.Status == WebExceptionStatus.RequestCanceled);
        }
コード例 #3
0
        /// <summary>
        /// Recursive call to unwrap inner exceptions.
        /// </summary>
        /// <param name="ex">An exception to unwrap.</param>
        /// <param name="sb">A string builder where to dump the exception details into.</param>
        private static void InterogateException(Exception ex, StringBuilder sb)
        {
            var exceptionMessage = ex.Unwrap();

            if (string.IsNullOrEmpty(exceptionMessage))
            {
                return;
            }

            sb.AppendLine(exceptionMessage);
        }
コード例 #4
0
ファイル: ExceptionHelper.cs プロジェクト: bfriesen/SignalR
        internal static bool IsRequestAborted(Exception exception)
        {
            exception = exception.Unwrap();

            // Support an alternative way to propagate aborted requests
            if (exception is OperationCanceledException)
            {
                return true;
            }

            var webException = exception as WebException;
            return (webException != null && webException.Status == WebExceptionStatus.RequestCanceled);
        }
コード例 #5
0
        private void Close(Exception exception)
        {
            if (Interlocked.Exchange(ref _reading, 0) == 1)
            {
                Debug.WriteLine("EventSourceReader: Connection Closed");
                if (Closed != null)
                {
                    if (exception != null)
                    {
                        exception = exception.Unwrap();
                    }

                    Closed(exception);
                }

                // Release the buffer
                _readBuffer = null;
            }
        }
コード例 #6
0
ファイル: ExceptionHelper.cs プロジェクト: nairit/SignalR
 internal static bool IsRequestAborted(Exception exception)
 {
     var webException = exception.Unwrap() as WebException;
     return (webException != null && webException.Status == WebExceptionStatus.RequestCanceled);
 }
コード例 #7
0
ファイル: AsyncStreamReader.cs プロジェクト: rllibby/SignalR
        private void Close(Exception exception)
        {
            var previousState = Interlocked.Exchange(ref _reading, State.Stopped);

            if (previousState != State.Stopped)
            {
                if (Closed != null)
                {
                    if (exception != null)
                    {
                        exception = exception.Unwrap();
                    }

                    Closed(exception);
                }

                lock (_bufferLock)
                {
                    // Release the buffer
                    _readBuffer = null;
                }
            }
        }
コード例 #8
0
        private void Close(Exception exception)
        {
            var previousState = Interlocked.Exchange(ref _reading, State.Stopped);

            if (previousState == State.Processing)
            {
                Debug.WriteLine("EventSourceReader: Connection Closed");
                if (Closed != null)
                {
                    if (exception != null)
                    {
                        exception = exception.Unwrap();
                    }

                    Closed(exception);
                }

                lock (_bufferLock)
                {
                    // Release the buffer
                    _readBuffer = null;
                }
            }

            if (previousState != State.Stopped && Disabled != null)
            {
                Disabled();
            }
        }