NegotiateStream.ReadTimeout 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定讀取作業封鎖等待資料的時間長度。
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( 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);
}
}
備註
這個屬性會傳回在基礎資料流程上叫 ReadTimeout 用 屬性所傳回的值。 當您設定此屬性時, ReadTimeout 基礎資料流程上的值會設定為指定的值。
如果基礎資料流程是 NetworkStream , ReadTimeout 則 以毫秒為單位,且預設會設定為 Infinite ,讓讀取作業不會逾時。