public override void WriteByte(byte value)
{
// Lock down the file stream while we do this.
lock (_lock)
{
CheckSessionIsOpen();
// Setup the object for writing.
SetupWrite();
// Flush the current buffer if it is full.
if (_bufferPosition >= _writeBufferSize)
{
using (var wait = new AutoResetEvent(false))
{
_session.RequestWrite(_handle, _serverFilePosition, _writeBuffer, 0, _bufferPosition, wait);
_serverFilePosition += (ulong) _bufferPosition;
}
_bufferPosition = 0;
}
// Write the byte into the buffer and advance the posn.
_writeBuffer[_bufferPosition++] = value;
++_position;
}
}