WebRequest.Timeout プロパティ
アセンブリ: System (system.dll 内)

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


Timeout プロパティは、要求がタイムアウトし、WebException をスローするまでのミリ秒単位の時間を指定します。Timeout プロパティは、GetResponse メソッドによる同期要求だけに適用されます。非同期要求をタイムアウトさせるには、Abort メソッドを使用します。
![]() |
---|
WebRequest クラスは、abstract クラスです。実行時の WebRequest インスタンスの実際の動作は、System.Net.WebRequest.Create メソッドで返される派生クラスによって決まります。既定値および例外の詳細については、HttpWebRequest や FileWebRequest などの派生クラスの説明を参照してください。 |

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();

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からWebRequest.Timeout プロパティを検索する場合は、下記のリンクをクリックしてください。

- WebRequest.Timeout プロパティのページへのリンク