示例#1
0
        public static MmfFile Create(IntPtr hFile, ulong maxLength)
        {
            if (maxLength < 0)
            {
                throw new ArgumentOutOfRangeException("maxLength");
            }

            MmfFile file = new MmfFile(hFile, maxLength, MemoryProtection.PageReadWrite);

            if (!file.IsPageFile)
            {
                file.SetMaxLength(Math.Max(maxLength, file.FileSize));
            }
            else
            {
                file.SetMaxLength(maxLength);
            }
            return(file);
        }
示例#2
0
        /// <summary>
        /// Initializes the ViewManager.
        /// </summary>
        /// <param name="mapper"></param>
        public void CreateInitialViews(uint initial)
        {
            _maxViews = initial;
            ulong maxSize    = _mmf.MaxLength;
            int   totalViews = (int)(maxSize / _viewSize);

            if (maxSize % _viewSize > 0)
            {
                totalViews++;
                _mmf.SetMaxLength((ulong)(totalViews * _viewSize));
            }

            for (uint i = 0; i < totalViews; i++)
            {
                View view = new View(_mmf, i, _viewSize);
                OpenView(view);
                CloseView(view);
            }

            ReOpenViews();
        }