TimeoutException 클래스
정의
프로세스나 작업에 할당된 시간이 만료될 때 throw되는 예외입니다.The exception that is thrown when the time allotted for a process or operation has expired.
public ref class TimeoutException : SystemException
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class TimeoutException : SystemException
type TimeoutException = class
inherit SystemException
Public Class TimeoutException
Inherits SystemException
- 상속
- 파생
- 특성
예제
다음 코드 예제는 사용 방법을 보여 줍니다 TimeoutException 의 멤버와 함께에서 System.IO.Ports.SerialPort 클래스입니다.The following code example demonstrates the use of TimeoutException in conjunction with members of the System.IO.Ports.SerialPort class.
// This example demonstrates the use of the TimeoutException
// exception in conjunction with the SerialPort class.
#using <System.dll>
using namespace System;
using namespace System::IO::Ports;
int main()
{
String^ input;
try
{
// Set the COM1 serial port to speed = 4800 baud, parity = odd,
// data bits = 8, stop bits = 1.
SerialPort^ port = gcnew SerialPort("COM1",
4800, Parity::Odd, 8, StopBits::One);
// Timeout after 2 seconds.
port->ReadTimeout = 2000;
port->Open();
// Read until either the default newline termination string
// is detected or the read operation times out.
input = port->ReadLine();
port->Close();
// Echo the input.
Console::WriteLine(input);
}
// Only catch timeout exceptions.
catch (TimeoutException^ ex)
{
Console::WriteLine(ex);
}
};
/*
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.
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.
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()
'
설명
설정 되기 전의 제한 시간 간격에 대 한 자세한는 TimeoutException 예외가, 해당 메서드 시간이 초과 되었습니다. 형식에 대 한 설명서를 참조 하십시오. 처리 제한 시간에 대 한 자세한 예외를 발생 시킨 메서드에 대 한 설명서를 참조 합니다.For information about setting the time-out interval before a TimeoutException exception is thrown, consult the documentation for the type whose method timed out. For information about handling the time-out, see the documentation for the method that threw the exception.
TimeoutException 값 0x80131505 COR_E_TIMEOUT HRESULT를 사용 합니다.TimeoutException uses the HRESULT, COR_E_TIMEOUT, which has the value 0x80131505.
인스턴스의 초기 속성 값의 목록을 TimeoutException, 참조는 TimeoutException 생성자입니다.For a list of initial property values for an instance of TimeoutException, see the TimeoutException constructors.
생성자
TimeoutException() |
TimeoutException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the TimeoutException class. |
TimeoutException(SerializationInfo, StreamingContext) |
serialize된 데이터를 사용하여 TimeoutException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the TimeoutException class with serialized data. |
TimeoutException(String) |
지정된 오류 메시지를 사용하여 TimeoutException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the TimeoutException class with the specified error message. |
TimeoutException(String, Exception) |
지정된 오류 메시지와 내부 예외를 사용하여 TimeoutException 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the TimeoutException class with the specified error message and inner exception. |
속성
Data |
예외에 대한 사용자 정의 추가 정보를 제공하는 키/값 쌍의 컬렉션을 가져옵니다.Gets a collection of key/value pairs that provide additional user-defined information about the exception. (다음에서 상속됨 Exception) |
HelpLink |
이 예외와 연결된 도움말 파일에 대한 링크를 가져오거나 설정합니다.Gets or sets a link to the help file associated with this exception. (다음에서 상속됨 Exception) |
HResult |
특정 예외에 할당된 코드화된 숫자 값인 HRESULT를 가져오거나 설정합니다.Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. (다음에서 상속됨 Exception) |
InnerException |
현재 예외를 발생시킨 Exception 인스턴스를 가져옵니다.Gets the Exception instance that caused the current exception. (다음에서 상속됨 Exception) |
Message |
현재 예외를 설명하는 메시지를 가져옵니다.Gets a message that describes the current exception. (다음에서 상속됨 Exception) |
Source |
오류를 발생시키는 애플리케이션 또는 개체의 이름을 가져오거나 설정합니다.Gets or sets the name of the application or the object that causes the error. (다음에서 상속됨 Exception) |
StackTrace |
호출 스택의 직접 실행 프레임에 대한 문자열 표현을 가져옵니다.Gets a string representation of the immediate frames on the call stack. (다음에서 상속됨 Exception) |
TargetSite |
현재 예외를 throw하는 메서드를 가져옵니다.Gets the method that throws the current exception. (다음에서 상속됨 Exception) |
메서드
Equals(Object) |
지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object. (다음에서 상속됨 Object) |
GetBaseException() |
파생 클래스에서 재정의되었을 때, 하나 이상의 후속 예외의 근본 원인이 되는 Exception을 반환합니다.When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (다음에서 상속됨 Exception) |
GetHashCode() |
기본 해시 함수로 작동합니다.Serves as the default hash function. (다음에서 상속됨 Object) |
GetObjectData(SerializationInfo, StreamingContext) |
파생 클래스에서 재정의될 때, 예외에 관한 정보를 SerializationInfo에 설정합니다.When overridden in a derived class, sets the SerializationInfo with information about the exception. (다음에서 상속됨 Exception) |
GetType() |
현재 인스턴스의 런타임 형식을 가져옵니다.Gets the runtime type of the current instance. (다음에서 상속됨 Exception) |
MemberwiseClone() |
현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object. (다음에서 상속됨 Object) |
ToString() |
현재 예외에 대한 문자열 표현을 만들고 반환합니다.Creates and returns a string representation of the current exception. (다음에서 상속됨 Exception) |
이벤트
SerializeObjectState |
예외에 대한 serialize된 데이터가 들어 있는 예외 상태 개체가 만들어지도록 예외가 serialize될 때 발생합니다.Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception. (다음에서 상속됨 Exception) |