Exemplo n.º 1
0
        public void UnSubscribeEvent(string eventName, EventProcessHandler handler)
        {
            lock (this)
            {
                Delegate handlerList = (Delegate)this.htableSubscribed[eventName];

                if (handlerList != null)
                {
                    handlerList = Delegate.Remove(handlerList, handler);
                    this.htableSubscribed[eventName] = handlerList;
                }
            }
        }
Exemplo n.º 2
0
        //handler是本地委托
        public void SubscribeEvent(string eventName, EventProcessHandler handler)
        {
            lock (this)
            {
                Delegate handlerList = (Delegate)this.htableSubscribed[eventName];
                if (handlerList == null)
                {
                    this.htableSubscribed.Add(eventName, handler);
                    this.eventServer.SubscribeEvent(eventName, new EventProcessHandler(this.OnRemoteEventHappen));
                    return;
                }

                handlerList = Delegate.Combine(handlerList, handler);
                this.htableSubscribed[eventName] = handlerList;
            }
        }