NegotiateStream.ReadTimeout Proprietà

Definizione

Ottiene o imposta l'intervallo di tempo per il quale un'operazione di lettura si blocca in attesa dei dati.

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

Valore della proprietà

Valore Int32 che specifica l'intervallo di tempo che deve trascorrere prima che l'operazione di lettura generi un errore.

Esempio

Nell'esempio di codice seguente viene illustrato il valore di questa proprietà.

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

Commenti

Questa proprietà restituisce il valore restituito richiamando la ReadTimeout proprietà nel flusso sottostante. Quando si imposta questa proprietà, il ReadTimeout valore del flusso sottostante è impostato sul valore specificato.

Se il flusso sottostante è un NetworkStreamoggetto , ReadTimeout è in millisecondi ed è impostato su Infinite per impostazione predefinita in modo che le operazioni di lettura non vengano timeout.

Si applica a