本文整理汇总了C#中System.IO.MemoryMappedFiles.MemoryMappedViewAccessor.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryMappedViewAccessor.ReadUInt16方法的具体用法?C# MemoryMappedViewAccessor.ReadUInt16怎么用?C# MemoryMappedViewAccessor.ReadUInt16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.MemoryMappedFiles.MemoryMappedViewAccessor
的用法示例。
在下文中一共展示了MemoryMappedViewAccessor.ReadUInt16方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRows
private void ProcessRows(MemoryMappedViewAccessor accessor)
{
UInt32 lastPos = 0;
_BlockCount = accessor.ReadUInt16(8);
_BlockSize = accessor.ReadUInt16(10);
while (true)
{
UInt32 curPos = accessor.ReadUInt32(4) % _BlockCount;
var bag = _MissingItems;
_MissingItems = new ConcurrentBag<int>();
int temp = 0;
while (bag.TryTake(out temp))
readLineAndProcess(accessor, temp);
if (lastPos == curPos)
{
System.Threading.Thread.Sleep(1000);
}
else
{
if (lastPos < curPos)
{
for (UInt32 x = lastPos; x < curPos; ++x)
readLineAndProcess(accessor, (int)x);
}
else
{
for (UInt32 x = lastPos; x < _BlockCount; ++x)
readLineAndProcess(accessor, (int)x);
for (UInt32 x = 0; x < curPos; ++x)
readLineAndProcess(accessor, (int)x);
}
lastPos = curPos;
}
};
}
示例2: LoadHeaderAndStreams
private void LoadHeaderAndStreams(PeHeaderReader pe, MemoryMappedViewAccessor mm)
{
var clrDataDir = pe.DataDirectories[PeHeaderReader.Image_Directory_Entry_Type.COM_DESCRIPTOR];
if (Marshal.SizeOf(typeof(IMAGE_COR20_HEADER)) != clrDataDir.Size)
throw new Exception("Size wrong.");
mm.Read<IMAGE_COR20_HEADER>(pe.GetFileOffset(clrDataDir.VirtualAddress), out mHeader);
if (mHeader.cb != clrDataDir.Size)
throw new Exception("Size wrong.");
var metaLoc = pe.GetFileOffset(mHeader.MetaData.VirtualAddress);
mm.Read<MetaDataHeaderPart1>(metaLoc, out mMetaHeader);
var versionBytes = new byte[mMetaHeader.VersionLength];
metaLoc += Marshal.SizeOf(typeof(MetaDataHeaderPart1));
mm.ReadArray<byte>(metaLoc, versionBytes, 0, versionBytes.Length);
int versionSize = 0;
while (versionSize < versionBytes.Length && versionBytes[versionSize] != 0)
versionSize++;
mVersionName = Encoding.ASCII.GetString(versionBytes, 0, versionSize);
metaLoc += mMetaHeader.VersionLength;
mMetaDataFlags = mm.ReadUInt16(metaLoc);
metaLoc += 2;
uint numberOfMetaStreams = mm.ReadUInt16(metaLoc);
metaLoc += 2;
for (int i = 0; i < numberOfMetaStreams; i++)
{
MetaDataStream mds;
mm.Read<MetaDataStream>(metaLoc, out mds);
metaLoc += Marshal.SizeOf(typeof(MetaDataStream));
byte b;
StringBuilder sb = new StringBuilder();
while ((b = mm.ReadByte(metaLoc++)) != 0)
{
sb.Append((char)b);
}
metaLoc += 3;
metaLoc &= ~3;
mMetaStreams.Add(sb.ToString(), mds);
}
}