Ejemplo n.º 1
0
        public void ScenarioWithSmartEventSourceNoRoot()
        {
            Debug.WriteLine("!!! Start diagnostics !!! ");

            var source   = new SmartEventSource();;
            var listener = new ConventionalEventListener(source);

            source.RaiseEvent(EventArgs.Empty);

            Debug.WriteLine("Setting listener to null.");
            listener = null;

            AttemptToTriggerGC();

            source.RaiseEvent(EventArgs.Empty);

            Debug.WriteLine("Setting source to null.");
            source = null;

            AttemptToTriggerGC();
        }
Ejemplo n.º 2
0
        public void SmartEventSourceMethodGroup()
        {
            Debug.WriteLine("!!! Start diagnostics !!! ");

            var source = new SmartEventSource();;

            var listener = new ConventionalEventListener();

            source.Event += listener.OnEvent;

            source.RaiseEvent(EventArgs.Empty);

            Debug.WriteLine("Setting listener to null.");
            listener = null;

            AttemptToTriggerGC();

            source.RaiseEvent(EventArgs.Empty);

            Debug.WriteLine("Setting source to null.");
            source = null;

            AttemptToTriggerGC();
        }
Ejemplo n.º 3
0
        public void ModifiedSmartSourceWithClosure()
        {
            Debug.WriteLine("!!! Start diagnostics !!! ");

            var source = new SmartEventSource();;

            var listener = new ConventionalEventListener();

            source.Event += (s, args) => listener.OnEvent(s, args);

            source.RaiseEvent(EventArgs.Empty);

            Debug.WriteLine("Setting listener to null.");
            listener = null;

            AttemptToTriggerGC();

            source.RaiseEvent(EventArgs.Empty);

            Debug.WriteLine("Setting source to null.");
            source = null;

            AttemptToTriggerGC();
        }
Ejemplo n.º 4
0
        public ConventionalEventListener(SmartEventSource source)
        {
            source.Event += this.OnEvent;

            Id = Guid.NewGuid();
        }