NegotiateStream.WriteTimeout Właściwość

Definicja

Pobiera lub ustawia czas, przez jaki operacja zapisu blokuje oczekiwanie na dane.

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

Wartość właściwości

Element Int32 określający czas, który upłynie przed niepowodzeniem operacji zapisu.

Przykłady

Poniższy przykład kodu przedstawia wyświetlanie wartości tej właściwości.

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

Uwagi

Ta właściwość zwraca wartość zwróconą przez wywołanie WriteTimeout właściwości w bazowym strumieniu. W przypadku operacji ustawiania określona wartość ustawia WriteTimeout wartość na bazowym strumieniu.

Jeśli bazowy strumień to NetworkStream, WriteTimeout jest wyrażony w milisekundach i jest domyślnie ustawiony na Infinite wartość , aby operacje zapisu nie upłynął limit czasu.

Dotyczy