WebRequest.Timeout プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
要求がタイムアウトするまでのミリ秒単位の時間を取得または設定します。
public:
virtual property int Timeout { int get(); void set(int value); };
public virtual int Timeout { get; set; }
member this.Timeout : int with get, set
Public Overridable Property Timeout As Integer
プロパティ値
要求がタイムアウトするまでの時間 (ミリ秒単位)、または要求がタイムアウトしないことを示す値 Infinite 。既定値は、子孫クラスによって定義されます。
例外
プロパティが派生クラスでオーバーライドされていないのに、そのプロパティの取得または設定が試行されました。
例
次の例では、 プロパティを Timeout 10000 ミリ秒に設定します。 リソースを返す前にタイムアウト期間が切れると、 WebException がスローされます。
// 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.
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()
注釈
プロパティは Timeout 、要求がタイムアウトして をスローするまでの時間の長さをミリ秒単位で WebException示します。 プロパティは Timeout 、 メソッドで GetResponse 行われた同期要求にのみ影響します。 非同期要求をタイムアウトにするには、 メソッドを使用します Abort 。
注意
クラスは WebRequest クラスです abstract
。 実行時のインスタンスの実際の WebRequest 動作は、 メソッドによって返される子孫クラスによって WebRequest.Create 決定されます。 既定値と例外の詳細については、 や などのHttpWebRequestFileWebRequest子孫クラスのドキュメントを参照してください。
注意 (継承者)
子孫クラスは、 フィールドを に設定して をWebExceptionスローすることでタイムアウトをTimeoutStatus通知します。 が にInfinite設定されている場合Timeout、子孫クラスはタイムアウトしません。
適用対象
こちらもご覧ください
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示