void MemoryUpdateEvent(object sender, MemoryUpdateEventArgs args) { List <WeakReference> deadStreams = new List <WeakReference>(); lock (mMemoryReaders) { foreach (WeakReference memStreamRef in mMemoryReaders) { DebugMemoryStream memStream = memStreamRef.Target as DebugMemoryStream; if (memStream == null) { deadStreams.Add(memStreamRef); continue; } memStream.Update(args.Address, args.Memory); } foreach (WeakReference deadref in deadStreams) { mMemoryReaders.Remove(deadref); } } }
public DebugMemoryStream NewMemoryStream() { lock (mMemoryReaders) { DebugMemoryStream dms = new DebugMemoryStream(this); mMemoryReaders.Add(new WeakReference(dms)); return(dms); } }