示例#1
0
 /// <summary>
 /// Unsubscribe the specify event with the specify token
 /// </summary>
 /// <param name="token">A event attact to a specify token</param>
 public virtual void InnerUnsubscribe(EventToken token)
 {
     lock (actions)
     {
         IEvent event1 = actions.FirstOrDefault(act => act.token == token);
         if (event1 != null)
         {
             actions.Remove(event1);
         }
     }
 }
示例#2
0
        /// <summary>
        /// Subscribe a event
        /// </summary>
        /// <param name="curAction"></param>
        protected virtual EventToken InnerSubscribe(IEvent curAction)
        {
            if (curAction == null)
            {
                throw new System.ArgumentNullException("curAction");
            }

            EventToken token = new EventToken(this.InnerUnsubscribe);

            lock (actions)
            {
                curAction.token = token;
                actions.Add(curAction);
            }

            return(token);
        }