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) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「TimeoutException クラス」の関連用語

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

   

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



TimeoutException クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS