public void Write(object data) { bool result = m_dataBuffer.Write(data); if (!result) { lock (m_dataStackLockObj) { if (m_dataBuffer.IsFull() && m_dataBuffer.Count > 0) { UpdateLastAutoFlushTime(); m_dataStack.Push(m_dataBuffer); Interlocked.Increment(ref _count); NewDataBuffer(); } } Write(data); } while (IsBlockMainThread) { long tmpCount = Interlocked.CompareExchange(ref _count, 0, 0); if (tmpCount < PoolSize) { break; } Thread.Sleep(100); } }