示例#1
0
        private void MapView()
        {
            var ptr = MapViewOfFile(_sharedMemoryHandle.GetHandle(),
                                    FileMapAccess.FileMapRead | FileMapAccess.FileMapWrite,
                                    0,
                                    0,
                                    Size);

            if (ptr == IntPtr.Zero)
            {
                throw new InvalidOperationException("File map not valid!");
            }
            if (Size == 0)
            {
                var info = new MemoryBasicInformation();

                VirtualQuery(ref ptr, ref info, Marshal.SizeOf(info));
                Size = info.RegionSize;
            }

            ShareMemoryStream = new SharedMemoryStream(ptr, Size);
        }
示例#2
0
        private void MapView()
        {
            var ptr = MapViewOfFile(_sharedMemoryHandle.GetHandle(),
                                    FileMapAccess.FileMapRead | FileMapAccess.FileMapWrite,
                                    0,
                                    0,
                                    Size);
            if (ptr == IntPtr.Zero)
            {
                throw new InvalidOperationException("File map not valid!");
            }
            if (Size == 0)
            {
                var info = new MemoryBasicInformation();

                VirtualQuery(ref ptr, ref info, Marshal.SizeOf(info));
                Size = info.RegionSize;
            }

            ShareMemoryStream = new SharedMemoryStream(ptr, Size);
        }