NegotiateStream.WriteTimeout 属性

定义

获取或设置写操作阻止等待数据的时间。

public:
 virtual property int WriteTimeout { int get(); void set(int value); };
public override int WriteTimeout { get; set; }
member this.WriteTimeout : int with get, set
Public Overrides Property WriteTimeout 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);
     }
}

注解

此属性返回通过调用 WriteTimeout 基础流上的 属性返回的值。 对于设置操作,指定的值设置 WriteTimeout 基础流上的值。

如果基础流为 ,NetworkStreamWriteTimeout则 以毫秒为单位,并且默认设置为 Infinite ,以便写入操作不会超时。

适用于