public void Flush() { dataSemaphore.WaitOne(); readPosition = 0; writePosition = 0; dataSemaphore.Release(); }