MemoryMappedViewAccessor 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示随机访问的内存映射文件视图。
public ref class MemoryMappedViewAccessor sealed : System::IO::UnmanagedMemoryAccessor
public sealed class MemoryMappedViewAccessor : System.IO.UnmanagedMemoryAccessor
type MemoryMappedViewAccessor = class
inherit UnmanagedMemoryAccessor
Public NotInheritable Class MemoryMappedViewAccessor
Inherits UnmanagedMemoryAccessor
- 继承
示例
以下示例从大型内存映射文件中获取 MemoryMappedViewAccessor 进行编辑。
此代码示例是为 MemoryMappedFile 类提供的一个更大示例的一部分。
// Create a random access view, from the 256th megabyte (the offset)
// to the 768th megabyte (the offset plus length).
using (var accessor = mmf.CreateViewAccessor(offset, length))
{
int colorSize = Marshal.SizeOf(typeof(MyColor));
MyColor color;
// Make changes to the view.
for (long i = 0; i < length; i += colorSize)
{
accessor.Read(i, out color);
color.Brighten(10);
accessor.Write(i, ref color);
}
}
' Create a random access view, from the 256th megabyte (the offset)
' to the 768th megabyte (the offset plus length).
Using accessor = mmf.CreateViewAccessor(offset, length)
Dim colorSize As Integer = Marshal.SizeOf(GetType(MyColor))
Dim color As MyColor
Dim i As Long = 0
' Make changes to the view.
Do While (i < length)
accessor.Read(i, color)
color.Brighten(10)
accessor.Write(i, color)
i += colorSize
Loop
End Using
注解
CreateViewAccessor使用 对象的 方法MemoryMappedFile获取此视图。
属性
CanRead |
确定访问器是否可读。 (继承自 UnmanagedMemoryAccessor) |
CanWrite |
确定访问器是否可写。 (继承自 UnmanagedMemoryAccessor) |
Capacity |
获取访问器的容量。 (继承自 UnmanagedMemoryAccessor) |
IsOpen |
确定访问器当前是否由进程打开。 (继承自 UnmanagedMemoryAccessor) |
PointerOffset |
获取此视图的开始位置相对于内存映射文件的开头进行偏移的字节数。 |
SafeMemoryMappedViewHandle |
获取内存映射文件的视图的句柄。 |
方法
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈