public void Init() { listener = new AppHTTPListener(); listener.Init(); wrapper = new AgentInterface.MMFWrapper(); bkStruct = new AgentInterface.InterfaceStruct(); }
private void WriteToMMF(InterfaceStruct st) { int size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(InterfaceStruct)); MemoryMappedViewAccessor accessor = mmfAgentStruct.CreateViewAccessor(); accessor.WriteArray(0, StructureToByteArray((object)st), 0, size); accessor.Dispose(); }
unsafe public void ReadMMF(ref InterfaceStruct st) { using (var stream = mmfAgentStruct.CreateViewStream()) { using (BinaryReader binReader = new BinaryReader(stream)) { object obj = (object)st; ByteArrayToStructure(binReader.ReadBytes((int)stream.Length), ref obj); st = (InterfaceStruct)obj; } } }
public void Update() { wrapper.ReadMMF(ref readStruct); if (bkStruct.state != readStruct.state) { Process_state((AppState)bkStruct.state, (AppState)readStruct.state); } bkStruct = DeepCopy <AgentInterface.InterfaceStruct>(readStruct); Thread.Sleep(100); }