有谁知道使用共享内存 pre 的 C# 开源实现吗? .NET 4.0(我们没有内存映射文件实现。
最好使用 id 索引。
最佳答案
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr CreateFileMapping(
IntPtr hFile,
IntPtr lpFileMappingAttributes,
FileMapProtection flProtect,
uint dwMaximumSizeHigh,
uint dwMaximumSizeLow,
[MarshalAs(UnmanagedType.LPTStr)] string lpName);
请参阅此处了解更多信息
http://www.pinvoke.net/default.aspx/kernel32.createfilemapping
和
http://msdn.microsoft.com/en-us/library/aa366551(v=vs.85).aspx
C# Cookbook 包含 SharedMemoryManager 的实现,您可以在此处查看: http://csharp.codefetch.com/example/p1/MutexFun/SharedMemoryManager.cs
关于C# 共享内存缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5516822/