NegotiateStream.ReadTimeout プロパティ

定義

読み取り操作がブロックしてデータを待機する時間を取得または設定します。

C#
public override int ReadTimeout { get; set; }

プロパティ値

読み取り操作が失敗するまでの経過時間を指定する Int32

次のコード例では、このプロパティの値を表示する方法を示します。

C#
 static void DisplayStreamProperties(NegotiateStream stream)
{
     Console.WriteLine("Can read: {0}", stream.CanRead);
     Console.WriteLine("Can write: {0}", stream.CanWrite);
     Console.WriteLine("Can seek: {0}", stream.CanSeek);
     try
     {
         // If the underlying stream supports it, display the length.
         Console.WriteLine("Length: {0}", stream.Length);
     } catch (NotSupportedException)
     {
             Console.WriteLine("Cannot get the length of the underlying stream.");
     }

     if (stream.CanTimeout)
     {
         Console.WriteLine("Read time-out: {0}", stream.ReadTimeout);
         Console.WriteLine("Write time-out: {0}", stream.WriteTimeout);
     }
}

注釈

このプロパティは、基になるストリームで プロパティを ReadTimeout 呼び出すことによって返される値を返します。 このプロパティを設定すると、 ReadTimeout 基になるストリームの値が指定した値に設定されます。

基になるストリームが の場合、 NetworkStreamReadTimeout はミリ秒単位で、読み取り操作がタイムアウトしないように既定で にInfinite設定されます。

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1