Esempio n. 1
0
 internal void AddEvent <T>(Action <object, T> item, EventState state, EventStack <T> stack) where T : EventArgs
 {
     if (!state.EventAdded)
     {
         lock (lockEvents)
         {
             stack.Push(item);
             state.EventAdded = true;
         }
     }
 }
Esempio n. 2
0
 internal void AddEvent <T>(Action <object, T> item, EventState state, EventStack <T> stack) where T : EventArgs
 {
     //If the event hasn't been added, add it and mark it as being added
     if (!state.EventAdded)
     {
         lock (lockEvents)
         {
             stack.Push(item);
             state.EventAdded = true;
         }
     }
 }
Esempio n. 3
0
        internal void RemoveEvent <T>(EventState state, EventStack <T> stack, bool resetState) where T : EventArgs
        {
            if (!state.EventRemoved && state.EventAdded)
            {
                lock (lockEvents)
                {
                    stack.Pop();
                    state.EventRemoved = true;
                }
            }

            if (resetState)
            {
                state.EventAdded   = false;
                state.EventRemoved = false;
            }
        }
Esempio n. 4
0
        internal void RemoveEvent <T>(EventState state, EventStack <T> stack, bool resetState) where T : EventArgs
        {
            //If the event hasn't been removed yet and was actually added, remove it
            if (!state.EventRemoved && state.EventAdded)
            {
                //Remove the event from the stack, and mark it as removed
                lock (lockEvents)
                {
                    stack.Pop();
                    state.EventRemoved = true;
                }
            }

            //The event was never added or removed in the first place. This allows us to re-add/remove
            //events again
            if (resetState)
            {
                state.EventAdded   = false;
                state.EventRemoved = false;
            }
        }