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 に設定しますTimeoutTimeout.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 プロパティ



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

辞書ショートカット

すべての辞書の索引

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

   

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



WebRequest.Timeout プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS