示例#1
0
        private static void _progressMainEvents(EventPairDic dic, EventObjList listWait, EventObjList listDo, bool isMainThread = false)
        {
            monitorEnter(dic);

            foreach (EventObj item in listWait)
            {
                listDo.AddLast(item);
            }
            listWait.Clear();

            monitorExit(dic);

            for (int i = 0; i < listDo.Count; i++)
            {
                var item = listDo.First.Value;
                try
                {
                    item.info.method.Invoke(item.info.obj, item.args);
                }
                catch (System.Exception e)
                {
                    LogFile.Error("progress " + (isMainThread ? "main" : "thread") + " event error: event[" + item.info.eventName + "]; msg: " + e.ToString());
                }
                listDo.RemoveFirst();
            }
        }
示例#2
0
        protected static bool _notifyEvent(EventPairDic dic, EventObjList list, string eventName, params object[] args)
        {
            monitorEnter(dic);

            EventPairList _list = null;

            if (!dic.TryGetValue(eventName, out _list))
            {
                //if (dic == sDicToMain)
                //{
                //    LogFile.Warn("sDicToMain do not have event named \"" + eventName + "\"");
                //}
                //else
                //{
                //    LogFile.Warn("sDicToThread do not have event named \"" + eventName + "\"");
                //}
                monitorExit(dic);

                return(false);
            }

            foreach (Pair item in _list)
            {
                EventObj _obj = new EventObj();
                _obj.info = item;
                _obj.args = args;
                list.AddLast(_obj);
            }

            monitorExit(dic);

            return(true);
        }