//
        //  Private Methods
        //

        private void PrivateAddHandler(ICommand source, EventHandler <EventArgs> handler)
        {
            // get the list of sinks for this source, creating if necessary
            List <HandlerSink> list = (List <HandlerSink>) this[source];

            if (list == null)
            {
                list         = new List <HandlerSink>();
                this[source] = list;
            }

            // add a new sink to the list
            HandlerSink sink = new HandlerSink(this, source, handler);

            list.Add(sink);

            // keep the handler alive
            AddHandlerToCWT(handler, _cwt);
        }
        private void PrivateRemoveHandler(ICommand source, EventHandler <EventArgs> handler)
        {
            // get the list of sinks for this source
            List <HandlerSink> list = (List <HandlerSink>) this[source];

            if (list != null)
            {
                HandlerSink sinkToRemove = null;
                bool        foundDirt    = false;

                // look for the given sink on the list
                foreach (HandlerSink sink in list)
                {
                    if (sink.Matches(source, handler))
                    {
                        sinkToRemove = sink;
                        break;
                    }
                    else if (sink.IsInactive)
                    {
                        foundDirt = true;
                    }
                }

                // remove the sink (outside the loop, to avoid re-entrancy issues)
                if (sinkToRemove != null)
                {
                    list.Remove(sinkToRemove);
                    sinkToRemove.Detach(isOnOriginalThread: true);
                    RemoveHandlerFromCWT(handler, _cwt);
                }

                // if we noticed any stale sinks, schedule a purge
                if (foundDirt)
                {
                    ScheduleCleanup();
                }
            }
        }
        //
        //  Private Methods
        //

        private void PrivateAddHandler(ICommand source, EventHandler<EventArgs> handler)
        {
            // get the list of sinks for this source, creating if necessary
            List<HandlerSink> list = (List<HandlerSink>)this[source];
            if (list == null)
            {
                list = new List<HandlerSink>();
                this[source] = list;
            }

            // add a new sink to the list
            HandlerSink sink = new HandlerSink(this, source, handler);
            list.Add(sink);

            // keep the handler alive
            AddHandlerToCWT(handler, _cwt);
        }