In writing mode, the number of bytes that can currently be written via Write() or WriteByte() without blocking.
In reading mode, returns the number of bytes that can currently be read via Read() or ReadByte() without blocking
or -1 if the end of the stream has been reached.
This property is read-only.
AsyncStream uses an internal buffer to cache input and output. Reading cached data or writing to the cache will never block. By reading or writing no more than Available bytes, blocking can be avoided.
AsyncStream asyncStream = new AsyncStream(File.OpenRead(@"C:\somefile.txt"),10); //...do something... byte[] myBuffer = new byte[10]; int read = 0; if (asyncStream.Available > 0) read = asyncStream.Read(myBuffer,0,asyncStream.Available); //will not block //...do something else... asyncStream.Close(); //cleanup
| Exception | Condition |
|---|---|
| ObjectDisposedException | The AsyncStream has already been closed |