NegotiateStream.WriteTimeout 属性

定义

获取或设置写操作阻止等待数据的时间。Gets or sets the amount of time a write operation blocks waiting for data.

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

Int32,指定写操作失败前经过的时间。A Int32 that specifies the amount of time that will elapse before a write operation fails.

示例

下面的代码示例演示如何显示此属性的值。The following code example demonstrates displaying the value of this property.

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

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


 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 对基础流调用属性返回的值。This property returns the value returned by invoking the WriteTimeout property on the underlying stream. 对于设置操作,指定的值将设置 WriteTimeout 基础流的值。For set operations, the specified value sets the WriteTimeout value on the underlying stream.

如果基础流为 NetworkStreamWriteTimeout 则以毫秒为单位,并且默认设置为, Infinite 以便写入操作不会超时。If the underlying stream is a NetworkStream, WriteTimeout is in milliseconds and is set to Infinite by default so that write operations do not time out.

适用于