Beispiel #1
0
 private void BindingEvents()
 {
     //
     // timer
     //
     timer.Tick += (sender, args) =>
     {
         HintTextIndex = (HintTextIndex + 1) % HintTexts.Length;
         if (!IsTimeOut)
         {
             TimeSpan span = DateTime.Now - _startTime;
             if (span.TotalSeconds > TimeOut)
             {
                 IsTimeOut = true;
             }
         }
     };
     //
     // this
     //
     Shown += (sender, args) =>
     {
         _startTime = DateTime.Now;
         timer.Start();
     };
     Closed += (sender, args) =>
     {
         if (timer != null && timer.Enabled)
         {
             timer.Stop();
             timer.Dispose();
         }
         if (WhenClosed != null)
         {
             WhenClosed.Invoke();
         }
     };
 }
Beispiel #2
0
        public virtual void Update(float delta)
        {
            if (recvMsgList == null)
            {
                return;
            }

            lock (recvMsgList)
            {
                tmpMsgList.AddRange(recvMsgList);
                recvMsgList.Clear();
            }

            if (tmpMsgList.Count > 0)
            {
                for (int i = 0; i < tmpMsgList.Count; i++)
                {
                    var msg      = tmpMsgList[i];
                    var fullname = msg.GetType().FullName;

                    if (msg.GetType().Name == "RpcMsg")
                    {
                        OnRpc((RpcMsg)msg);
                    }
                    else
                    {
                        var msgInfo = msgDefined.GetMsgByName(fullname);
                        if (msgInfo != null)
                        {
                            events.Fire(msgInfo.Name, msg);
                            if (msg is IMsg)
                            {
                                ((IMsg)msg).Recycle();
                            }
                        }
                    }
                }

                tmpMsgList.Clear();
            }

            lock (eventList)
            {
                for (int i = 0; i < eventList.Count; i++)
                {
                    var e = eventList[i];
                    switch (e.eventType)
                    {
                    case EventType.Connected:
                        if (WhenConnected != null)
                        {
                            WhenConnected.Invoke();
                        }

                        heartThread = new Thread(HeartThread);
                        heartThread.IsBackground = true;
                        bHeartThreadQuit         = false;
                        heartThread.Start();
                        break;

                    case EventType.Closed:
                        StopHeart();
                        if (WhenClosed != null)
                        {
                            WhenClosed.Invoke(null);
                        }
                        break;

                    case EventType.Error:
                        if (WhenError != null)
                        {
                            WhenError.Invoke(e.ex);
                        }
                        break;
                    }
                }

                eventList.Clear();
            }
        }