• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# MemoryMappedFiles.MemoryMappedViewAccessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.IO.MemoryMappedFiles.MemoryMappedViewAccessor的典型用法代码示例。如果您正苦于以下问题:C# MemoryMappedViewAccessor类的具体用法?C# MemoryMappedViewAccessor怎么用?C# MemoryMappedViewAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MemoryMappedViewAccessor类属于System.IO.MemoryMappedFiles命名空间,在下文中一共展示了MemoryMappedViewAccessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetPrivateOffset

 // This is a Reflection hack to workaround clr bug 6441.  
 //
 // MemoryMappedViewAccessor.SafeMemoryMappedViewHandle.AcquirePointer returns a pointer
 // that has been aligned to SYSTEM_INFO.dwAllocationGranularity.  Unfortunately the 
 // offset from this pointer to our requested offset into the MemoryMappedFile is only
 // available through the UnmanagedMemoryStream._offset field which is not exposed publicly.
 //
 private long GetPrivateOffset(MemoryMappedViewAccessor stream)
 {
     System.Reflection.FieldInfo unmanagedMemoryStreamOffset = typeof(MemoryMappedViewAccessor).GetField("m_view", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetField);
     object memoryMappedView = unmanagedMemoryStreamOffset.GetValue(stream);
     System.Reflection.PropertyInfo memoryMappedViewPointerOffset = memoryMappedView.GetType().GetProperty("PointerOffset", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty);
     return (long)memoryMappedViewPointerOffset.GetValue(memoryMappedView);
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:14,代码来源:MemoryMappedFileBlock.cs


示例2: CVarBuf

 public CVarBuf(MemoryMappedViewAccessor mapView, CiRSDKHeader header)
 {
     FileMapView = mapView;
     Header = header;
     VarHeaderSize = Marshal.SizeOf(typeof(VarHeader));
     VarBufSize = Marshal.SizeOf(typeof(VarBuf));
 }
开发者ID:mochablendy,项目名称:iRacingSdkWrapper,代码行数:7,代码来源:CVarBuf.cs


示例3: MappedBuffer

 public MappedBuffer(MemoryMappedViewAccessor view, int pos, int len)
 {
     this.view = view;
     this.pos = pos;
     this.len = len;
     Check.Slice(pos, len, view.Capacity);
 }
开发者ID:apmckinlay,项目名称:nsuneido,代码行数:7,代码来源:MappedBuffer.cs


示例4: MemoryMappedFileBlock

        internal unsafe MemoryMappedFileBlock(MemoryMappedViewAccessor accessor)
        {
            byte* ptr = null;
            accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr);
            ptr += GetPrivateOffset(accessor);

            this.accessor = accessor;
            this.pointer = (IntPtr)ptr;
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:9,代码来源:MemoryMappedFileBlock.cs


示例5: MemoryMappedReadWriteContext

        public MemoryMappedReadWriteContext(MemoryMappedViewAccessor viewAccessor,
            MemoryMappedViewStream viewStream, Mutex accessMutex, bool lockOnCreate)
        {
            ViewAccessor = viewAccessor;
            ViewStream = viewStream;
            _accessMutex = accessMutex;

            if (lockOnCreate)
                Lock();
        }
开发者ID:gaxar77,项目名称:Tibayan,代码行数:10,代码来源:ReadWriteContext.cs


示例6: StreamHeaderRef

        public StreamHeaderRef(MemoryMappedViewAccessor accessor)
        {
            Accessor = accessor;
            Buffer = accessor.GetSafeBuffer();

            byte* temp = null;
            Buffer.AcquirePointer(ref temp);

            Ptr = (StreamHeader*)temp;
        }
开发者ID:sq,项目名称:DataMangler,代码行数:10,代码来源:StreamRef.cs


示例7: ReadBytes

        public static unsafe void ReadBytes(MemoryMappedViewAccessor view, long offset, ref long[] arr)
        {
            //byte[] arr = new byte[num];
            var ptr = (byte*)0;

            view.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr);
            var ip = new IntPtr(ptr);
            var iplong = ip.ToInt64() + offset;
            var ptr_off = new IntPtr(iplong);

            Marshal.Copy(ptr_off, arr, 0, 512);
            view.SafeMemoryMappedViewHandle.ReleasePointer();
        }
开发者ID:IOActive,项目名称:inVtero.net,代码行数:13,代码来源:UnsafeHelp.cs


示例8: MapContent

 void MapContent()
 {
     if (_accessor != null) return;
     _memoryMappedFile = MemoryMappedFile.CreateFromFile(_stream, null, 0, MemoryMappedFileAccess.ReadWrite, null, HandleInheritability.None, true);
     _accessor = _memoryMappedFile.CreateViewAccessor();
     _accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref _pointer);
 }
开发者ID:mano-cz,项目名称:BTDB,代码行数:7,代码来源:OnDiskMemoryMappedFileCollection.cs


示例9: BitmapBroadcaster

 public BitmapBroadcaster()
 {
     file = MemoryMappedFile.CreateOrOpen("OpenNiVirtualCamFrameData", fileSize, MemoryMappedFileAccess.ReadWrite);
     memoryAccessor = file.CreateViewAccessor(0, fileSize, MemoryMappedFileAccess.ReadWrite);
     if (hasServer())
         throw new Exception("Only one server is allowed.");
 }
开发者ID:pasinduc,项目名称:NiVirtualCam,代码行数:7,代码来源:BitmapBroadcaster.cs


示例10: MemoryMapReader

        public MemoryMapReader(string file)
        {
            var fileInfo = new FileInfo(file);

            Length = (int)fileInfo.Length;

            // Ideally we would use the file ID in the mapName, but it is not
            // easily available from C#.
            var mapName = $"{fileInfo.FullName.Replace("\\", "-")}-{Length}";
            lock (FileLocker)
            {
                try
                {
                    _memoryMappedFile = MemoryMappedFile.OpenExisting(mapName, MemoryMappedFileRights.Read);
                }
                catch (Exception ex) when (ex is IOException || ex is NotImplementedException)
                {
                    using (
                        var stream = new FileStream(file, FileMode.Open, FileAccess.Read,
                            FileShare.Delete | FileShare.Read))
                    {
                        _memoryMappedFile = MemoryMappedFile.CreateFromFile(stream, mapName, Length,
                            MemoryMappedFileAccess.Read, null, HandleInheritability.None, false);
                    }
                }
            }

            _view = _memoryMappedFile.CreateViewAccessor(0, Length, MemoryMappedFileAccess.Read);
        }
开发者ID:RalphSim,项目名称:MaxMind-DB-Reader-dotnet,代码行数:29,代码来源:MemoryMapReader.cs


示例11: MemoryMappedFileCheckpoint

        public MemoryMappedFileCheckpoint(string filename, string name, bool cached, bool mustExist = false, long initValue = 0)
        {
            _filename = filename;
            _name = name;
            _cached = cached;
            var old = File.Exists(_filename);
            _fileStream = new FileStream(_filename,
                                            mustExist ? FileMode.Open : FileMode.OpenOrCreate,
                                            FileAccess.ReadWrite,
                                            FileShare.ReadWrite);
            _file = MemoryMappedFile.CreateFromFile(_fileStream,
                                                    Guid.NewGuid().ToString(),
                                                    sizeof(long),
                                                    MemoryMappedFileAccess.ReadWrite,
                                                    new MemoryMappedFileSecurity(),
                                                    HandleInheritability.None,
                                                    false);
            _accessor = _file.CreateViewAccessor(0, 8);

            if (old)
                _last = _lastFlushed = ReadCurrent();
            else
            {
                _last = initValue;
                Flush();
            }
        }
开发者ID:rcknight,项目名称:AppDotNetEvents,代码行数:27,代码来源:MemoryMappedFileCheckpoint.cs


示例12: SRHSharedData

        public SRHSharedData()
        {
            m_Mmf = MemoryMappedFile.CreateNew(@"SimpleROHook1008",
                Marshal.SizeOf(typeof(StSHAREDMEMORY)),
                MemoryMappedFileAccess.ReadWrite);
            if (m_Mmf == null)
                MessageBox.Show("CreateOrOpen MemoryMappedFile Failed.");
            m_Accessor = m_Mmf.CreateViewAccessor();

            byte* p = null;
            m_Accessor.SafeMemoryMappedViewHandle.AcquirePointer(ref p);
            m_pSharedMemory = (StSHAREDMEMORY*)p;

            write_packetlog = false;
            freemouse = false;
            m2e = false;
            fix_windowmode_vsyncwait = false;
            show_framerate = false;
            objectinformation = false;
            _44khz_audiomode = false;
            cpucoolerlevel = 0;
            configfilepath = "";
            musicfilename = "";
            executeorder = false;
            g_hROWindow = 0;
        }
开发者ID:Jasty777,项目名称:SimpleROHook,代码行数:26,代码来源:SRHSharedData.cs


示例13: Dispose

        public void Dispose()
        {
            if (_accessor != null)
                _accessor.Dispose();

            _accessor = null;
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:7,代码来源:MemoryMappedFileByteBuffer.cs


示例14: Startup

        //List<CVarHeader> VarHeaders = new List<CVarHeader>();

        public bool Startup()
        {
            if (IsInitialized) return true;

            try
            {
                iRacingFile = MemoryMappedFile.OpenExisting(Defines.MemMapFileName);
                FileMapView = iRacingFile.CreateViewAccessor();
                
                VarHeaderSize = Marshal.SizeOf(typeof(VarHeader));

                var hEvent = OpenEvent(Defines.DesiredAccess, false, Defines.DataValidEventName);
                var are = new AutoResetEvent(false);
                are.Handle = hEvent;

                var wh = new WaitHandle[1];
                wh[0] = are;

                WaitHandle.WaitAny(wh);

                Header = new CiRSDKHeader(FileMapView);
                GetVarHeaders();

                IsInitialized = true;
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
开发者ID:mochablendy,项目名称:iRacingSdkWrapper,代码行数:33,代码来源:iRacingSDK.cs


示例15: MumbleLink

 public MumbleLink()
 {
     if (mmFile == null)
     {
         mmFile = MemoryMappedFile.CreateOrOpen("MumbleLink", Marshal.SizeOf(data), MemoryMappedFileAccess.ReadWrite);
         mmAccessor = mmFile.CreateViewAccessor(0, Marshal.SizeOf(data));
     }
 }
开发者ID:Danmashel,项目名称:Gw2MappingLink,代码行数:8,代码来源:MumbleLink.cs


示例16: cFileMap

 public cFileMap(FileStream stream, FileMapProtect protect, int offset, int length)
 {
     MemoryMappedFileAccess cProtect = (protect == FileMapProtect.ReadWrite) ? MemoryMappedFileAccess.ReadWrite : MemoryMappedFileAccess.Read;
     _length = length;
     _mappedFile = MemoryMappedFile.CreateFromFile(stream, stream.Name, _length, cProtect, null, HandleInheritability.None, true);
     _mappedFileAccessor = _mappedFile.CreateViewAccessor(offset, _length, cProtect);
     _addr = _mappedFileAccessor.SafeMemoryMappedViewHandle.DangerousGetHandle();
 }
开发者ID:chrisall76,项目名称:Sm4sh-Tools,代码行数:8,代码来源:FileMap.cs


示例17: MemoryMappedFileCommunicator

        public MemoryMappedFileCommunicator(MemoryMappedFile rpMemoryMappedFile, long rpOffset, long rpSize, MemoryMappedFileAccess rpAccess)
        {
            r_MemoryMappedFile = rpMemoryMappedFile;
            r_ViewAccessor = rpMemoryMappedFile.CreateViewAccessor(rpOffset, rpSize, rpAccess);

            ReadPosition = -1;
            r_WritePosition = -1;
        }
开发者ID:amatukaze,项目名称:IntelligentNavalGun-Fx4,代码行数:8,代码来源:MemoryMappedFileCommunicator.cs


示例18: Allocate

		public void Allocate()
		{
			//we can't allocate 0 bytes here.. so just allocate 1 byte here if 0 was requested. it should be OK, and we dont have to handle cases where blocks havent been allocated
			int sizeToAlloc = Size;
			if (sizeToAlloc == 0) sizeToAlloc = 1;
			mmf = MemoryMappedFile.CreateNew(BlockName, sizeToAlloc);
			mmva = mmf.CreateViewAccessor();
			mmva.SafeMemoryMappedViewHandle.AcquirePointer(ref Ptr);
		}
开发者ID:ddugovic,项目名称:RASuite,代码行数:9,代码来源:SharedMemoryBlock.cs


示例19: SetBlockEntry

 private void SetBlockEntry(int index)
 {
     if (BlockEntryIndex != index)
     {
         BlockEntry.Dispose();
         BlockEntry = File.CreateViewAccessor(
             BlockEntryOffset + (BlockEntrySize * index), BlockEntrySize, MemoryMappedFileAccess.Read);
     }
 }
开发者ID:Frassle,项目名称:Ibasa,代码行数:9,代码来源:Gcf.cs


示例20: UnmapContent

 void UnmapContent()
 {
     if (_accessor == null) return;
     _accessor.SafeMemoryMappedViewHandle.ReleasePointer();
     _accessor.Dispose();
     _accessor = null;
     _memoryMappedFile.Dispose();
     _memoryMappedFile = null;
 }
开发者ID:mano-cz,项目名称:BTDB,代码行数:9,代码来源:OnDiskMemoryMappedFileCollection.cs



注:本文中的System.IO.MemoryMappedFiles.MemoryMappedViewAccessor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Packaging.Package类代码示例发布时间:2022-05-26
下一篇:
C# MemoryMappedFiles.MemoryMappedFile类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap