本文整理汇总了C#中System.IO.MemoryMappedFiles.MemoryMappedFile.CreateViewAccessor方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryMappedFile.CreateViewAccessor方法的具体用法?C# MemoryMappedFile.CreateViewAccessor怎么用?C# MemoryMappedFile.CreateViewAccessor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.MemoryMappedFiles.MemoryMappedFile
的用法示例。
在下文中一共展示了MemoryMappedFile.CreateViewAccessor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SharedMemory
public SharedMemory(string name, IntPtr size)
{
mmf = MemoryMappedFile.OpenExisting(name + "_CONNECT_DATA");
mmva = mmf.CreateViewAccessor();
if (mmf.SafeMemoryMappedFileHandle.IsInvalid)
throw new MySqlException("Cannot open file mapping " + name);
mmvs = mmf.CreateViewStream(0L, size.ToInt64());
mmva = mmf.CreateViewAccessor(0L, size.ToInt64());
}
示例2: MemoryMappedFileMessageSender
public MemoryMappedFileMessageSender(string name)
{
_file = MemoryMappedFile.CreateOrOpen(name, SizeOfFile);
_bytesWrittenAccessor = _file.CreateViewAccessor(0, SizeOfInt32);
_messageCompletedAccessor = _file.CreateViewAccessor(SizeOfInt32, SizeOfBool);
_stream = _file.CreateViewStream(SizeOfInt32 + SizeOfBool + SizeOfBool, SizeOfStream);
_messageSendingEvent = new EventWaitHandle(false, EventResetMode.AutoReset, name + "_MessageSending");
_messageReadEvent = new EventWaitHandle(false, EventResetMode.AutoReset, name + "_MessageRead");
_messageCancelledEvent = new EventWaitHandle(false, EventResetMode.ManualReset, name + "_MessageCancelled");
_bytesWrittenEvent = new EventWaitHandle(false, EventResetMode.AutoReset, name + "_BytesWritten");
_bytesReadEvent = new EventWaitHandle(false, EventResetMode.AutoReset, name + "_BytesRead");
}
示例3: 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;
}
示例4: 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);
}
示例5: 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.");
}
示例6: 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();
}
}
示例7: 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;
}
示例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);
}
示例9: MumbleLink
public MumbleLink()
{
if (mmFile == null)
{
mmFile = MemoryMappedFile.CreateOrOpen("MumbleLink", Marshal.SizeOf(data), MemoryMappedFileAccess.ReadWrite);
mmAccessor = mmFile.CreateViewAccessor(0, Marshal.SizeOf(data));
}
}
示例10: Gcf
public Gcf(FileStream fileStream)
{
File = MemoryMappedFile.CreateFromFile(fileStream, System.IO.Path.GetFileNameWithoutExtension(fileStream.Name), 0,
MemoryMappedFileAccess.Read, null, HandleInheritability.None, true);
FileHeader = File.CreateViewAccessor(FileHeaderOffset, FileHeaderSize, MemoryMappedFileAccess.Read);
BlockEntryHeader = File.CreateViewAccessor(BlockEntryHeaderOffset, BlockEntryHeaderSize, MemoryMappedFileAccess.Read);
BlockEntryIndex = 0;
BlockEntry = File.CreateViewAccessor(BlockEntryOffset, BlockEntrySize, MemoryMappedFileAccess.Read);
FragmentationMapHeader = File.CreateViewAccessor(
FragmentationMapHeaderOffset, FragmentationMapHeaderSize, MemoryMappedFileAccess.Read);
FragmentationMapIndex = 0;
FragmentationMap = File.CreateViewAccessor(FragmentationMapOffset, FragmentationMapSize, MemoryMappedFileAccess.Read);
}
示例11: 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();
}
示例12: 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;
}
示例13: deserializeFromMemoryMappedFile
public object deserializeFromMemoryMappedFile(MemoryMappedFile mmf,ref int index,int length)
{
int createLength = (int)length;
using (MemoryMappedViewAccessor mmfReader = mmf.CreateViewAccessor()) {
byte[] buffer = new byte[length];
mmfReader.ReadArray<byte>(index, buffer, 0,createLength);
return ByteArrayToObject(buffer);
}
}
示例14: DebuggerForm
public DebuggerForm()
{
InitializeComponent();
m_MMF = MemoryMappedFile.CreateOrOpen( @"VoronoiDebugger", 1 << 20, MemoryMappedFileAccess.ReadWrite );
m_View = m_MMF.CreateViewAccessor( 0, 1 << 20, MemoryMappedFileAccess.ReadWrite ); // Open in R/W even though we won't write into it, just because we need to have the same access privileges as the writer otherwise we make the writer crash when it attempts to open the file in R/W mode!
integerTrackbarControlCell_ValueChanged( null, 0 );
}
示例15: 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);
}