The BetterStreams Class Library
Available Property
Namespaces > BetterStreams > AsyncStream > Available
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.
Syntax
C#Visual BasicManaged C++
public virtual int Available { get; }
Public Overridable ReadOnly Property Available As Integer
public:
virtual property int Available {
	int get ();
}
Remarks

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.

Examples
CopyC#
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
Exceptions
ExceptionCondition
ObjectDisposedExceptionThe AsyncStream has already been closed

Assembly: BetterStreams (Module: BetterStreams) Version: 1.0.0.0