public void Dispose() { if (!bDisposed) { bDisposed = true; GC.SuppressFinalize(this); if (!bOwnsStream) { bAPICall = true; Class.API(ref Tag, ClassTag, Buffer, (ushort)(BufferPosition | DisposingBit)); bAPICall = false; } else { bAPICall = true; try { Class.API(ref Tag, ClassTag, Buffer, (ushort)(BufferPosition | DisposingBit)); } finally { bAPICall = false; ((IDisposable)Class).Dispose(); } } } }