protected override MemoryBlock DoGetBlock()
        {
            lock (m_GetLock)
            {
                if (m_CurrentDeleteHandler == null)
                {
                    // Create new TempFile
                    string     l_FilePath   = Path.Combine(m_CacheDirectory, Guid.NewGuid().ToString());
                    FileStream l_FileStream = new FileStream(l_FilePath, FileMode.CreateNew);

                    if (m_BlocksPerFile != 1)
                    {
                        l_FileStream.SetLength(m_BlocksPerFile * GetBlockSize());
                    }

                    m_CurrentDeleteHandler = new StreamManagerFilePoolDeleteHandler(l_FileStream, m_BlocksPerFile);
                }

                StreamManagerFilePoolDeleteHandler l_DeleteHandler = m_CurrentDeleteHandler;
                long l_Offset = (m_BlocksPerFile - l_DeleteHandler.GetFreeBlockCount()) * GetBlockSize();
                l_DeleteHandler.IncRefCount();

                if (l_DeleteHandler.GetFreeBlockCount() == 0)
                {
                    m_CurrentDeleteHandler = null;
                }

                return(new FileMemoryBlock(this, l_DeleteHandler.GetStream(), l_Offset, l_DeleteHandler));
            }
        }
        protected override void DoReturnBlock(MemoryBlock p_Block)
        {
            // Delete the TempFile
            FileMemoryBlock l_Block = (FileMemoryBlock)p_Block;
            StreamManagerFilePoolDeleteHandler l_DeleteHandler = l_Block.DeleteHandler;

            l_DeleteHandler.DecRefCount();
        }
 public FileMemoryBlock(StreamManagerPool p_Pool, Stream p_Stream, long p_Offset, StreamManagerFilePoolDeleteHandler p_DeleteHandler) : base(p_Pool)
 {
     m_Stream        = p_Stream;
     m_Offset        = p_Offset;
     m_DeleteHandler = p_DeleteHandler;
 }