Example #1
0
        public void Thaw()
        {
            List <EventData> pendingEvents = null;

            lock (events) {
                if (--frozen == 0)
                {
                    pendingEvents = events;
                    events        = new List <EventData> ();
                }
            }
            if (pendingEvents != null)
            {
                for (int n = 0; n < pendingEvents.Count; n++)
                {
                    EventData ev  = pendingEvents [n];
                    Delegate  del = ev.Delegate();
                    if (ev.Args is IEventArgsChain)
                    {
                        EventData next = n < pendingEvents.Count - 1 ? pendingEvents [n + 1] : null;
                        if (next != null && (next.Args.GetType() == ev.Args.GetType()) && next.Delegate() == del && next.ThisObject == ev.ThisObject)
                        {
                            ((IEventArgsChain)next.Args).MergeWith((IEventArgsChain)ev.Args);
                            continue;
                        }
                    }
                    if (del != null)
                    {
                        del.DynamicInvoke(ev.ThisObject, ev.Args);
                    }
                }
            }
        }