C# Класс GitSharp.Core.Util.TimeoutStream

A normal Stream might provide a timeout on a specific read opreation. However, using StreamReader.ReadToEnd() on it can still get stuck for a long time. This class offers a timeout from the moment of it's construction to the read. Every read past the timeout from the stream's construction will fail. If the timeout elapsed while a read is in progress TimeoutStream is not responsible for aborting the read (there is no known good way in .NET to do it) See http://www.dotnet247.com/247reference/msgs/36/182553.aspx and http://www.google.co.il/search?q=cancel+async+Stream+read+.net Stream originalStream = GetStream(); StreamReader reader = new StreamReader(new TimeoutStream(originalStream, 5000)); // assuming the originalStream has a per-operation timeout, then ReadToEnd() // will return in (5000 + THAT_TIMEOUT) string foo = reader.ReadToEnd();
Наследование: Stream
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Flush ( ) : void
Read ( byte buffer, int offset, int count ) : int
Seek ( long offset, SeekOrigin origin ) : long
SetLength ( long value ) : void
TimeoutStream ( Stream stream, int timeoutMillis ) : System
Write ( byte buffer, int offset, int count ) : void

Приватные методы

Метод Описание
CheckTimeout ( ) : void

Описание методов

Flush() публичный Метод

public Flush ( ) : void
Результат void

Read() публичный Метод

public Read ( byte buffer, int offset, int count ) : int
buffer byte
offset int
count int
Результат int

Seek() публичный Метод

public Seek ( long offset, SeekOrigin origin ) : long
offset long
origin SeekOrigin
Результат long

SetLength() публичный Метод

public SetLength ( long value ) : void
value long
Результат void

TimeoutStream() публичный Метод

public TimeoutStream ( Stream stream, int timeoutMillis ) : System
stream Stream
timeoutMillis int
Результат System

Write() публичный Метод

public Write ( byte buffer, int offset, int count ) : void
buffer byte
offset int
count int
Результат void