static void AddTimerWait(MethodAnnotations ma) { Timer timer = null; WeakReference weakSelf = new WeakReference(ma); timer = new Timer(a => { timer.Dispose(); var self = (MethodAnnotations)weakSelf.Target; if (self != null) { self.ClearGarbageCollectedItems(); AddTimerWait(self); } }, null, DELETE_GCD_ITEMS_EVERY_MS, Timeout.Infinite); }
static void AddTimerWait(MethodAnnotations ma) { Timer? timer = null; WeakReference weakSelf = new WeakReference(ma); timer = new Timer(a => { Debug2.Assert(!(timer is null)); timer.Dispose(); if (weakSelf.Target is MethodAnnotations self) { self.ClearGarbageCollectedItems(); AddTimerWait(self); } }, null, Timeout.Infinite, Timeout.Infinite); timer.Change(DELETE_GCD_ITEMS_EVERY_MS, Timeout.Infinite); }