TimeoutExceptionとは? わかりやすく解説

TimeoutException クラス

指定したタイムアウト時間が経過するとスローされる例外。

名前空間: System.ServiceProcess
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)
構文構文

<SerializableAttribute> _
Public Class TimeoutException
    Inherits SystemException
Dim instance As TimeoutException
[SerializableAttribute] 
public class TimeoutException : SystemException
[SerializableAttribute] 
public ref class TimeoutException : public
 SystemException
/** @attribute SerializableAttribute() */ 
public class TimeoutException extends SystemException
SerializableAttribute 
public class TimeoutException extends
 SystemException
解説解説

TimeoutException クラスでは、例外の原因を説明するメッセージを指定できます。通常、この例外がメソッドによってスローされる場合は、"指定したタイムアウトが経過したため、操作は完了しませんでした。" などのメッセージが表示されます。

たとえば、このクラスは、ServiceController クラスの WaitForStatus メンバによって使用されます。サービスの Status プロパティを Paused から ContinuePending に変更するなどの操作を行うと、この例外がスローされる可能性があります。

継承階層継承階層
System.Object
   System.Exception
     System.SystemException
      System.ServiceProcess.TimeoutException
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TimeoutException メンバ
System.ServiceProcess 名前空間
WaitForStatus
ServiceController.Status プロパティ
ServiceController クラス
ServiceControllerStatus 列挙体

TimeoutException クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

プロセスまたは操作用に割り当てられた時間が経過したときにスローされる例外。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class TimeoutException
    Inherits SystemException
Dim instance As TimeoutException
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public class TimeoutException : SystemException
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class TimeoutException : public
 SystemException
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public class TimeoutException extends SystemException
SerializableAttribute 
ComVisibleAttribute(true) 
public class TimeoutException extends
 SystemException
解説解説

TimeoutException は、値 0x80131505 を保持する HRESULT, COR_E_TIMEOUT を使用します。

TimeoutException のインスタンスの初期プロパティ値の一覧については、TimeoutException コンストラクタのトピックを参照してください。

使用例使用例

System.IO.Ports.SerialPort クラスのメンバと組み合わせて TimeoutException を使用するコード例を次に示します。

' This example demonstrates the use of the TimeoutException 
' exception in conjunction with the SerialPort class.

Imports System
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 'Main
End Class 'Sample
'
'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.

#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.

import System.*;
import System.IO.Ports.*;

class Sample
{
    public static void main(String[]
 args)
    {
        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.set_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);
        }
    } //main
} //Sample

/*
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()
*/
継承階層継承階層
System.Object
   System.Exception
     System.SystemException
      System.TimeoutException
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

TimeoutException コンストラクタ ()

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

TimeoutException クラスの新しいインスタンスを初期化します。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As New TimeoutException
public TimeoutException ()
public:
TimeoutException ()
public TimeoutException ()
public function TimeoutException ()
解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TimeoutException クラス
TimeoutException メンバ
System 名前空間

TimeoutException コンストラクタ ()


TimeoutException コンストラクタ (String)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

TimeoutException クラスの新しいインスタンスを、指定したエラー メッセージを使用して初期化します。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TimeoutException クラス
TimeoutException メンバ
System 名前空間

TimeoutException コンストラクタ (SerializationInfo, StreamingContext)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

シリアル化したデータを使用して、TimeoutException クラスの新しいインスタンスを初期化します。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
Dim info As SerializationInfo
Dim context As StreamingContext

Dim instance As New TimeoutException(info,
 context)
protected TimeoutException (
    SerializationInfo info,
    StreamingContext context
)
protected:
TimeoutException (
    SerializationInfo^ info, 
    StreamingContext context
)
protected TimeoutException (
    SerializationInfo info, 
    StreamingContext context
)
protected function TimeoutException (
    info : SerializationInfo, 
    context : StreamingContext
)

パラメータ

info

スローされる例外に関するシリアル化されたオブジェクト データを格納する SerializationInfo オブジェクト。

context

転送元または転送先に関する文脈情報を格納する StreamingContext オブジェクト。context パラメータは、今後使用するために予約されているため、null 参照 (Visual Basic では Nothing) として指定できます。

例外例外
例外の種類条件

ArgumentNullException

info パラメータが null 参照 (Visual Basic では Nothing) です。

SerializationException

クラス名が null 参照 (Visual Basic では Nothing) であるか、HResult が 0 です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TimeoutException クラス
TimeoutException メンバ
System 名前空間
SerializationInfo
StreamingContext
その他の技術情報
バイナリ シリアル化

TimeoutException コンストラクタ (String, Exception)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

指定したエラー メッセージと内部例外を使用して、TimeoutException クラスの新しいインスタンスを初期化します。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    message As String, _
    innerException As Exception _
)
Dim message As String
Dim innerException As Exception

Dim instance As New TimeoutException(message,
 innerException)
public TimeoutException (
    string message,
    Exception innerException
)
public:
TimeoutException (
    String^ message, 
    Exception^ innerException
)
public TimeoutException (
    String message, 
    Exception innerException
)
public function TimeoutException (
    message : String, 
    innerException : Exception
)

パラメータ

message

エラーを説明するメッセージ。

innerException

現在の例外の原因である例外。innerException パラメータが null 参照 (Visual Basic では Nothing) でない場合は、内部例外を処理する catch ブロックで現在の例外が発生します。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TimeoutException クラス
TimeoutException メンバ
System 名前空間

TimeoutException コンストラクタ (String)

メッセージ テキストを指定して、TimeoutException クラスの新しいインスタンスを初期化します。

名前空間: System.ServiceProcess
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)
構文構文

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

TimeoutException コンストラクタ (SerializationInfo, StreamingContext)

指定したシリアル化情報とコンテキストを使用して、TimeoutException クラスの新しいインスタンスを初期化します。

名前空間: System.ServiceProcess
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)
構文構文

Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
Dim info As SerializationInfo
Dim context As StreamingContext

Dim instance As New TimeoutException(info,
 context)
protected TimeoutException (
    SerializationInfo info,
    StreamingContext context
)
protected:
TimeoutException (
    SerializationInfo^ info, 
    StreamingContext context
)
protected TimeoutException (
    SerializationInfo info, 
    StreamingContext context
)
protected function TimeoutException (
    info : SerializationInfo, 
    context : StreamingContext
)

パラメータ

info

スローされている例外に関するシリアル化済みオブジェクト データを保持している SerializationInfo。

context

転送元または転送先に関するコンテキスト情報を含んでいる StreamingContext。

例外例外
例外の種類条件

ArgumentNullException

info パラメータが null 参照 (Visual Basic では Nothing) です。

SerializationException

クラス名が null 参照 (Visual Basic では Nothing) であるか、または HResult が 0 です。

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

TimeoutException コンストラクタ (String, Exception)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

指定したメッセージ テキストと内部例外を使用して、TimeoutException クラスの新しいインスタンスを初期化します。

名前空間: System.ServiceProcess
アセンブリ: System.ServiceProcess (system.serviceprocess.dll 内)
構文構文

Public Sub New ( _
    message As String, _
    innerException As Exception _
)
Dim message As String
Dim innerException As Exception

Dim instance As New TimeoutException(message,
 innerException)
public TimeoutException (
    string message,
    Exception innerException
)
public:
TimeoutException (
    String^ message, 
    Exception^ innerException
)
public TimeoutException (
    String message, 
    Exception innerException
)
public function TimeoutException (
    message : String, 
    innerException : Exception
)

パラメータ

message

例外の種類または原因を説明するテキスト。

innerException

現在の例外を引き起こした例外。

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TimeoutException クラス
TimeoutException メンバ
System.ServiceProcess 名前空間
InnerException

TimeoutException コンストラクタ


TimeoutException コンストラクタ


TimeoutException プロパティ


パブリック プロパティパブリック プロパティ

プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ HResult  特定の例外に割り当てられているコード化数値である HRESULT を取得または設定します。 ( Exception から継承されます。)
参照参照

関連項目

TimeoutException クラス
System.ServiceProcess 名前空間
WaitForStatus
ServiceController.Status プロパティ
ServiceController クラス
ServiceControllerStatus 列挙体

TimeoutException プロパティ


パブリック プロパティパブリック プロパティ

プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ HResult  特定の例外に割り当てられているコード化数値である HRESULT を取得または設定します。 ( Exception から継承されます。)
参照参照

関連項目

TimeoutException クラス
System 名前空間
Exception クラス

その他の技術情報

例外の処理とスロー

TimeoutException メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TimeoutException クラス
System.ServiceProcess 名前空間
WaitForStatus
ServiceController.Status プロパティ
ServiceController クラス
ServiceControllerStatus 列挙体

TimeoutException メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TimeoutException クラス
System 名前空間
Exception クラス

その他の技術情報

例外の処理とスロー

TimeoutException メンバ

指定したタイムアウト時間が経過するとスローされる例外。

TimeoutException データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
プロテクト コンストラクタプロテクト コンストラクタ
パブリック プロパティパブリック プロパティ
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ HResult  特定の例外に割り当てられているコード化数値である HRESULT を取得または設定します。(Exception から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TimeoutException クラス
System.ServiceProcess 名前空間
WaitForStatus
ServiceController.Status プロパティ
ServiceController クラス
ServiceControllerStatus 列挙体

TimeoutException メンバ

プロセスまたは操作用に割り当てられた時間が経過したときにスローされる例外。

TimeoutException データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
プロテクト コンストラクタプロテクト コンストラクタ
パブリック プロパティパブリック プロパティ
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ HResult  特定の例外に割り当てられているコード化数値である HRESULT を取得または設定します。(Exception から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TimeoutException クラス
System 名前空間
Exception クラス

その他の技術情報

例外の処理とスロー



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「TimeoutException」の関連用語

TimeoutExceptionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TimeoutExceptionのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS