次の方法で共有


NegotiateStream.ReadTimeout プロパティ

定義

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

public:
 virtual property int ReadTimeout { int get(); void set(int value); };
public override int ReadTimeout { get; set; }
member this.ReadTimeout : int with get, set
Public Overrides Property ReadTimeout As Integer

プロパティ値

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

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

 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設定されます。

適用対象