WebRequest.Timeout プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WebRequest.Timeout プロパティの意味・解説 

WebRequest.Timeout プロパティ

要求がタイムアウトするまでの時間を取得または設定します。

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

Dim instance As WebRequest
Dim value As Integer

value = instance.Timeout

instance.Timeout = value
/** @property */
public int get_Timeout ()

/** @property */
public void set_Timeout (int
 value)

プロパティ値
要求がタイムアウトするまでのミリ秒単位の時間または要求がタイムアウトしないことを示す値 Timeout.Infinite。既定値は、派生クラスによって定義されます。

例外例外
例外の種類条件

NotImplementedException

プロパティが派生クラスでオーバーライドされていないのに、そのプロパティの取得または設定が試行されました。

解説解説

Timeout プロパティは、要求がタイムアウトし、WebException をスローするまでのミリ秒単位の時間を指定します。Timeout プロパティは、GetResponse メソッドによる同期要求だけに適用されます。非同期要求をタイムアウトさせるには、Abort メソッドを使用します。

メモメモ

WebRequest クラスは、abstract クラスです。実行時の WebRequest インスタンスの実際の動作は、System.Net.WebRequest.Create メソッドで返される派生クラスによって決まります。既定値および例外の詳細については、HttpWebRequest や FileWebRequest などの派生クラスの説明を参照してください。

継承時の注意 派生クラスは、WebException をスローしてタイムアウトを通知し、Status フィールドを WebExceptionStatus.Timeout に設定します。Timeout が Timeout.Infinite に設定されている場合、派生クラスはタイムアウトしません。

使用例使用例

Timeout プロパティを 10000 ミリ秒に設定する例を次に示します。リソースが返される前にタイムアウト時間が経過すると、WebException がスローされます。

   ' Create a new WebRequest Object to the mentioned URL.
   Dim myWebRequest As WebRequest = WebRequest.Create("http://www.contoso.com")
   Console.WriteLine(ControlChars.Cr + "The Timeout time of the
 request before setting is : {0} milliseconds", myWebRequest.Timeout)

   ' Set the 'Timeout' property in Milliseconds.
myWebRequest.Timeout = 10000

  ' Assign the response object of 'WebRequest' to a 'WebResponse' variable.
   Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

         // Create a new WebRequest Object to the mentioned URL.
WebRequest myWebRequest=WebRequest.Create("http://www.contoso.com");
Console.WriteLine("\nThe Timeout time of the request before setting is : {0}
 milliseconds",myWebRequest.Timeout);

// Set the 'Timeout' property in Milliseconds.
myWebRequest.Timeout=10000;

// This request will throw a WebException if it reaches the timeout
 limit before it is able to fetch the resource.
         WebResponse myWebResponse=myWebRequest.GetResponse();

// Create a new WebRequest Object to the mentioned URL.
WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com"
 );
Console::WriteLine( "\nThe Timeout time of the request before setting is : {0}
 milliseconds", myWebRequest->Timeout );

// Set the 'Timeout' property in Milliseconds.
myWebRequest->Timeout = 10000;

// This request will throw a WebException if it reaches the timeout
 limit
// before it is able to fetch the resource.
WebResponse^ myWebResponse = myWebRequest->GetResponse();
// Create a new WebRequest Object to the mentioned URL.
WebRequest myWebRequest = WebRequest.Create("http://www.contoso.com");
Console.WriteLine("\nThe Timeout time of the request before "
    + "setting is : {0} milliseconds", System.Convert.ToString(
    myWebRequest.get_Timeout()));
// Set the 'Timeout' property in Milliseconds.
myWebRequest.set_Timeout(10000);
// This request will throw a WebException if it reaches the 
// timeout limit before it is able to fetch the resource.
WebResponse myWebResponse = myWebRequest.GetResponse();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WebRequest クラス
WebRequest メンバ
System.Net 名前空間
HttpWebRequest.Timeout プロパティ



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

WebRequest.Timeout プロパティのお隣キーワード
検索ランキング

   

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



WebRequest.Timeout プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS