TimeoutException 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
프로세스 또는 작업에 할당된 시간이 만료되었을 때 throw되는 예외입니다.
public ref class TimeoutException : Exception
public ref class TimeoutException : SystemException
public class TimeoutException : Exception
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class TimeoutException : SystemException
public class TimeoutException : SystemException
type TimeoutException = class
inherit Exception
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type TimeoutException = class
inherit SystemException
type TimeoutException = class
inherit SystemException
Public Class TimeoutException
Inherits Exception
Public Class TimeoutException
Inherits SystemException
- 상속
- 상속
- 파생
- 특성
예제
다음 코드 예제에서는 클래스의 TimeoutException 멤버와 함께 사용 하는 방법을 보여 줍니다 System.IO.Ports.SerialPort .
// This example demonstrates the use of the TimeoutException
// exception in conjunction with the SerialPort class.
using System;
using System.IO.Ports;
class Sample
{
public static void Main()
{
string input;
try
{
// Set the COM1 serial port to speed = 4800 baud, parity = odd,
// data bits = 8, stop bits = 1.
SerialPort sp = new SerialPort("COM1",
4800, Parity.Odd, 8, StopBits.One);
// Timeout after 2 seconds.
sp.ReadTimeout = 2000;
sp.Open();
// Read until either the default newline termination string
// is detected or the read operation times out.
input = sp.ReadLine();
sp.Close();
// Echo the input.
Console.WriteLine(input);
}
// Only catch timeout exceptions.
catch (TimeoutException e)
{
Console.WriteLine(e);
}
}
}
/*
This example produces the following results:
(Data received at the serial port is echoed to the console if the
read operation completes successfully before the specified timeout period
expires. Otherwise, a timeout exception like the following is thrown.)
System.TimeoutException: The operation has timed-out.
at System.IO.Ports.SerialStream.ReadByte(Int32 timeout)
at System.IO.Ports.SerialPort.ReadOneChar(Int32 timeout)
at System.IO.Ports.SerialPort.ReadTo(String value)
at System.IO.Ports.SerialPort.ReadLine()
at Sample.Main()
*/
// This example demonstrates the use of the TimeoutException
// exception in conjunction with the SerialPort class.
open System
open System.IO.Ports
try
// Set the COM1 serial port to speed = 4800 baud, parity = odd,
// data bits = 8, stop bits = 1.
let sp = new SerialPort("COM1", 4800, Parity.Odd, 8, StopBits.One)
// Timeout after 2 seconds.
sp.ReadTimeout <- 2000
sp.Open()
// Read until either the default newline termination string
// is detected or the read operation times out.
let input = sp.ReadLine()
sp.Close()
// Echo the input.
printfn $"{input}"
// Only catch timeout exceptions.
with :? TimeoutException as e ->
printfn $"{e}"
(*
This example produces the following results:
(Data received at the serial port is echoed to the console if the
read operation completes successfully before the specified timeout period
expires. Otherwise, a timeout exception like the following is thrown.)
System.TimeoutException: The operation has timed-out.
at System.IO.Ports.SerialStream.ReadByte(Int32 timeout)
at System.IO.Ports.SerialPort.ReadOneChar(Int32 timeout)
at System.IO.Ports.SerialPort.ReadTo(String value)
at System.IO.Ports.SerialPort.ReadLine()
at Sample.main()
*)
' This example demonstrates the use of the TimeoutException
' exception in conjunction with the SerialPort class.
Imports System.IO.Ports
Class Sample
Public Shared Sub Main()
Dim input As String
Try
' Set the COM1 serial port to speed = 4800 baud, parity = odd,
' data bits = 8, stop bits = 1.
Dim sp As New SerialPort("COM1", 4800, Parity.Odd, 8, StopBits.One)
' Timeout after 2 seconds.
sp.ReadTimeout = 2000
sp.Open()
' Read until either the default newline termination string
' is detected or the read operation times out.
input = sp.ReadLine()
sp.Close()
' Echo the input.
Console.WriteLine(input)
' Only catch timeout exceptions.
Catch e As TimeoutException
Console.WriteLine(e)
End Try
End Sub
End Class
'
'This example produces the following results:
'
'(Data received at the serial port is echoed to the console if the
'read operation completes successfully before the specified timeout period
'expires. Otherwise, a timeout exception like the following is thrown.)
'
'System.TimeoutException: The operation has timed-out.
' at System.IO.Ports.SerialStream.ReadByte(Int32 timeout)
' at System.IO.Ports.SerialPort.ReadOneChar(Int32 timeout)
' at System.IO.Ports.SerialPort.ReadTo(String value)
' at System.IO.Ports.SerialPort.ReadLine()
' at Sample.Main()
'
설명
예외가 throw되기 전에 제한 시간 간격을 TimeoutException 설정하는 방법에 대한 자세한 내용은 메서드가 시간 초과된 형식에 대한 설명서를 참조하세요. 제한 시간 처리에 대한 자세한 내용은 예외를 throw한 메서드에 대한 설명서를 참조하세요.
TimeoutException 는 값이 0x80131505 HRESULT, COR_E_TIMEOUT 사용합니다.
TimeoutException인스턴스의 초기 속성 값 목록은 TimeoutException 생성자를 참조하세요.
생성자
| Name | Description |
|---|---|
| TimeoutException() |
TimeoutException 클래스의 새 인스턴스를 초기화합니다. |
| TimeoutException(SerializationInfo, StreamingContext) |
직렬화된 데이터를 사용하여 클래스의 새 인스턴스를 TimeoutException 초기화합니다. |
| TimeoutException(String, Exception) |
지정된 오류 메시지와 내부 예외를 TimeoutException 사용하여 클래스의 새 인스턴스를 초기화합니다. |
| TimeoutException(String) |
지정된 오류 메시지를 사용하여 클래스의 TimeoutException 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| Data |
예외에 대한 추가 사용자 정의 정보를 제공하는 키/값 쌍의 컬렉션을 가져옵니다. (다음에서 상속됨 Exception) |
| HelpLink |
이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다. (다음에서 상속됨 Exception) |
| HResult |
특정 예외에 할당된 코딩된 숫자 값인 HRESULT를 가져오거나 설정합니다. (다음에서 상속됨 Exception) |
| InnerException |
현재 예외를 Exception 발생시킨 인스턴스를 가져옵니다. (다음에서 상속됨 Exception) |
| Message |
현재 예외를 설명하는 메시지를 가져옵니다. (다음에서 상속됨 Exception) |
| Source |
오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다. (다음에서 상속됨 Exception) |
| StackTrace |
호출 스택에서 직접 실행 프레임의 문자열 표현을 가져옵니다. (다음에서 상속됨 Exception) |
| TargetSite |
현재 예외를 throw하는 메서드를 가져옵니다. (다음에서 상속됨 Exception) |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetBaseException() |
파생 클래스에서 재정의되는 경우 하나 이상의 후속 예외의 근본 원인인 값을 반환 Exception 합니다. (다음에서 상속됨 Exception) |
| GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
| GetObjectData(SerializationInfo, StreamingContext) |
파생 클래스에서 재정의되는 경우 예외에 SerializationInfo 대한 정보를 사용하여 설정합니다. (다음에서 상속됨 Exception) |
| GetType() |
현재 인스턴스의 런타임 형식을 가져옵니다. (다음에서 상속됨 Exception) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 예외의 문자열 표현을 만들고 반환합니다. (다음에서 상속됨 Exception) |
이벤트
| Name | Description |
|---|---|
| SerializeObjectState |
예외에 대한 직렬화된 데이터를 포함하는 예외 상태 개체를 만들기 위해 예외가 serialize될 때 발생합니다. (다음에서 상속됨 Exception) |