Beispiel #1
0
 private void ThreadMain()
 {
     CurrentContext = this;
     mThreadId      = System.Threading.Thread.CurrentThread.ManagedThreadId;
     OnThreadStart();
     while (mIsRun)
     {
         var time1 = Support.Time.GetTickCount();
         try
         {
             Tick();
         }
         catch (Exception ex)
         {
             Profiler.Log.WriteException(ex);
         }
         finally
         {
             ContextThread.CurrentContext.ExitWhenFrameFinished();
         }
         var time2 = Support.Time.GetTickCount();
         if (time2 - time1 < Interval)
         {
             System.Threading.Thread.Sleep(Interval - (int)(time2 - time1));
         }
     }
     mIsFinished = true;
     OnThreadExited();
     CurrentContext = null;
 }
Beispiel #2
0
 public void FromCurrent(string name)
 {
     if (mThreadId == 0)
     {
         mThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
         if (CurrentContext == null)
         {
             CurrentContext = this;
         }
         mIsRun    = true;
         this.Name = name;
     }
     this.OnThreadStart();
 }