Esempio n. 1
0
        /// <summary>
        /// Dispatch the specified type, target and args. sync type. 
        /// </summary>
        public virtual void DispatchEvent( Enum type, FEventParams args )
        {
            List<CallBack<FEventParams>> handlerList = mEventDic.ContainsKey (type) ? mEventDic[type] : null;
            if (handlerList != null && ContainEvent (type))
            {
                for (short i = 0; i < handlerList.Count; i++)
                {
                    CallBack<FEventParams> handler = handlerList[i];
                    if (mUseOnceEventDic.ContainsKey (type) && mUseOnceEventDic[type].Contains (handlerList[i]))
                    {
                        RemoveEvent (type, handler);
                        i--;
                    }
                    try
                    {
                        handler (args);
                    }
                    catch (Exception error)
                    {
                        try
                        {
                            EventHandlerError (error);
                            args.Dispose ();
                        }
                        catch (Exception)
                        {
                        }
                    }
                    if (i >= 0 && handlerList[i] != handler)
                        i--;

                    if (args.IsCancelDefaultAction)
                    {
                        args.Dispose ();
                        break;
                    }
                    args.Dispose ();
                }
            }
        }
Esempio n. 2
0
 public virtual void DispatchThreadEvent( Enum type, FEventParams args )
 {
     ///////////////
     List<CallBack<FEventParams>> handlerList = mEventDic.ContainsKey (type) ? mEventDic[type] : null;
     if (handlerList != null && ContainEvent (type))
     {
         for (short i = 0; i < handlerList.Count; i++)
         {
             Thread thread = new Thread (( object state ) => handlerList[i] (state as FEventParams));
             thread.Start (args);
             if (mUseOnceEventDic.ContainsKey (type) && mUseOnceEventDic[type].Contains (handlerList[i]))
             {
                 RemoveEvent (type, handlerList[i]);
                 i--;
             }
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Dispatch the specified type, target and args. async type, in idle frame execute function
 /// </summary>
 public virtual void DispatchAsyncEvent( Enum type, FEventParams args )
 {
     List<CallBack<FEventParams>> handlerList = mEventDic.ContainsKey (type) ? mEventDic[type] : null;
     if (handlerList != null && ContainEvent (type))
     {
         for (short i = 0; i < handlerList.Count; i++)
         {
             mAsyncEventList.Add (new FEventInfo () {
                 args = args, eventHandler = handlerList[i]
             });
             if (mUseOnceEventDic.ContainsKey (type) && mUseOnceEventDic[type].Contains (handlerList[i]))
             {
                 RemoveEvent (type, handlerList[i]);
                 i--;
             }
         }
     }
 }