當前位置: 首頁>>代碼示例>>C#>>正文


C# Exception.Unwrap方法代碼示例

本文整理匯總了C#中System.Exception.Unwrap方法的典型用法代碼示例。如果您正苦於以下問題:C# Exception.Unwrap方法的具體用法?C# Exception.Unwrap怎麽用?C# Exception.Unwrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Exception的用法示例。


在下文中一共展示了Exception.Unwrap方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ExceptionViewModel

        public ExceptionViewModel(Exception exception)
        {
            DisplayName = "An unhandled exception occurred";
            CloseCommand = new RelayCommand(TryClose);

            _exception = exception.Unwrap().ToAggregate();
        }
開發者ID:henjuv,項目名稱:Mg2,代碼行數:7,代碼來源:ExceptionViewModel.cs

示例2: IsRequestAborted

        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);
        }
開發者ID:Choulla-Naresh8264,項目名稱:SignalR,代碼行數:25,代碼來源:ExceptionHelper.cs

示例3: IsRequestAborted

        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);
        }
開發者ID:bfriesen,項目名稱:SignalR,代碼行數:13,代碼來源:ExceptionHelper.cs

示例4: Close

        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;
            }
        }
開發者ID:Kazzje,項目名稱:SignalR,代碼行數:19,代碼來源:EventSourceStreamReader.cs

示例5: IsRequestAborted

 internal static bool IsRequestAborted(Exception exception)
 {
     var webException = exception.Unwrap() as WebException;
     return (webException != null && webException.Status == WebExceptionStatus.RequestCanceled);
 }
開發者ID:nairit,項目名稱:SignalR,代碼行數:5,代碼來源:ExceptionHelper.cs

示例6: Close

        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;
                }
            }
        }
開發者ID:rllibby,項目名稱:SignalR,代碼行數:23,代碼來源:AsyncStreamReader.cs

示例7: Close

        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();
            }
        }
開發者ID:rustd,項目名稱:SignalR,代碼行數:29,代碼來源:EventSourceStreamReader.cs


注:本文中的System.Exception.Unwrap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。