Exemple #1
0
 public void Act(PlayerExecutable action)
 {
     lock (this.m_queue)
     {
         this.m_queue.Enqueue(action);
     }
 }
Exemple #2
0
 private void m_timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (this.m_state == ePlayerState.Stopped)
     {
         this.Stop();
         this.m_queue = new Queue <PlayerExecutable>();
     }
     else
     {
         m_lifeTime += 100;
         PlayerExecutable executable = null;
         lock (this.m_queue)
         {
             if (this.m_queue.Count > 0)
             {
                 executable = this.m_queue.Dequeue();
             }
         }
         if (executable != null)
         {
             try
             {
                 executable();
             }
             catch (Exception exception)
             {
                 this.m_state   = ePlayerState.Stopped;
                 this.LastError = exception.Message;
                 Console.WriteLine("player[{0}] execute error:{1}", this.m_account, exception.Message);
                 Console.WriteLine(exception.StackTrace);
             }
         }
     }
 }