예제 #1
0
            public void Add(PortableDispatcher dispatcher, PropertyChangedEventHandler eventHandler)
            {
                EventHandlersForDispatcher handlersForDispatcher = _list.FirstOrDefault(i => i.Dispatcher == dispatcher);

                if (handlersForDispatcher == null)
                {
                    handlersForDispatcher = new EventHandlersForDispatcher(dispatcher);
                    _list.Add(handlersForDispatcher);
                }

                // If the event handler isn't in the list yet, add it
                if (!handlersForDispatcher.Contains(eventHandler))
                {
                    handlersForDispatcher.Add(eventHandler);
                }
            }
예제 #2
0
        public static PortableDispatcher GetCurrentDispatcher()
        {
            if (ObtainDispatcherFunction == null)
            {
                throw new NullReferenceException("ObtainDispatcherFunction cannot be null");
            }

            PortableDispatcher d = ObtainDispatcherFunction();

            if (d == null)
            {
                throw new NullReferenceException("ObtainDispatcherFunction must return an initialized dispatcher.");
            }

            return(d);
        }
예제 #3
0
 public EventHandlersForDispatcher(PortableDispatcher dispatcher)
 {
     Dispatcher = dispatcher;
 }