public void runEventWithCustomArgs()
        {
            bool doEvent = false;

            doEvent = true;
            if (doEvent)
            {
                OnThingHappened?.Invoke(this, new EventArgWithInt(42));
            }
        }
Beispiel #2
0
        //EventHandler is in system - its a predefined delegate.
        //events are delegates
        //events do NOT have to be eventhandler, they can be your own delegate, but usually just use eventhandler
        //events by convention, usually start with "On"

        public void runSimpleEvent()
        {
            bool thingHappened = false;

            thingHappened = true;
            if (thingHappened)
            {
                //this is an older way to check null...
                //if (OnThingHappened != null)
                //{
                //    OnThingHappened.Invoke(this, EventArgs.Empty);
                //}
                OnThingHappened?.Invoke(this, EventArgs.Empty);
            }
        }