示例#1
0
        public void Should_Hold_Debounce_References_Weakly()
        {
            WeakReference?sampleRef  = null;
            WeakReference?sampleRef2 = null;

            new Action(() =>
            {
                var sample  = new DebouncingSample();
                var sample2 = new DebouncingSample();

                sampleRef  = new WeakReference(sample);
                sampleRef2 = new WeakReference(sample2);

                sample.DebounceHere();
                sample2.DebounceHere();
            }).Invoke();

            GC.Collect();

            Assert.False(sampleRef !.IsAlive);
            Assert.False(sampleRef2 !.IsAlive);
        }
示例#2
0
 static bool LocalDebounce(DebouncingSample sample) => sample.DebounceHere();