private void _OnMemoryChange() { var checks = new FiveList <Guid, IntPtr, Action <object>, Type, object>(); while (true) { Thread.Sleep(100); lock (CheckChangeLock) { checks.AddRange(CheckChange.Where(c => !checks.Select(p => p.V1).Contains(c.V1)).Select(p => new Five <Guid, IntPtr, Action <object>, Type, object>(p.V1, p.V2, p.V3, p.V4, null))); checks.RemoveRange(checks.Where(p => !CheckChange.Select(c => c.V1).Contains(p.V1))); } foreach (var check in checks) { object invokeValue = null; switch (check.V4.Name.ToUpper()) { case "BYTE": var value = ReadByte(check.V2); if (check.V5 == null || value != (byte)check.V5) { invokeValue = value; } break; case "SHORT": case "UINT16": var valueShort = ReadShort(check.V2); if (check.V5 == null || valueShort != (short)check.V5) { invokeValue = valueShort; } break; case "INT": case "UINT": case "UINT32": var valueInt = ReadInt(check.V2); if (check.V5 == null || valueInt != (uint)check.V5) { invokeValue = valueInt; } break; case "LONG": case "ULONG": case "UINT64": var valueLong = ReadLong(check.V2); if (check.V5 == null || valueLong != (ulong)check.V5) { invokeValue = valueLong; } break; } if (invokeValue != null) { check.V3.Invoke(invokeValue); check.V5 = invokeValue; } } } }
public Timers() { TimerList = new FiveList <string, int, object, Thread, EventHandler <int> >(); }