title: Old question: how to kill a thread immediately in c#
body: <p>I am writing a chess game which allows two programs compete, the player needs to write a DLL and expose a function to tell the main application where this player will move in the next, suppose the function looks like </p>
  
  <pre><code>public static void MoveNext(out int x, out int y, out int discKind);
  </code></pre>
  
  <p>In the chess game application, I start a new thread to call the function that the player's DLL exposed to get where he will move in a turn, and I start a timer to prevent the player timeouts</p>
  
  <pre><code> private Thread mPlayerMoveThread;
  
   private void SetPlayerToMove(IPlayer player)
          {
              this.CurrentPlayer = player;
  
              try
              {
  
                      System.Threading.Timer mTimeoutTimer = 
                                    new Timer(new TimerCallback(TimeIsUp), 
                                    null, 
                                    this.mMaxTimeOfOnePlayer, 
                                    Timeout.Infinite);
  
                      mPlayerMoveThread = new Thread(this.ThreadMethodPlayerAction);
                      mPlayerMoveThread.IsBackground = true;
                      mPlayerMoveThread.Start();
              }
              catch(Exception ex)
              {
                  //// invalid move, so finish the game
                  HandleInvalidMove(player.Color, ex);
              }
          }
  
   private void ThreadMethodPlayerAction()
          {
              this.CurrentPlayer.MoveNext();
          }
  
          private void KillThread(Thread thread)
          {
              if (thread == null || thread.ThreadState == ThreadState.Stopped)
                  return;
  
              try
              {
                  thread.Abort();
                  thread.Join();
              }
              catch
              {
              }
              finally
              {
                  thread = null;
              }
  
          }
  
          private void TimeIsUp(object state)
          {
              // kill the threads
              KillThread(mPlayerMoveThread);
  
              HandleInvalidMove(this.CurrentPlayer.Color, new Exception("timeout"));
          }
  </code></pre>
  
  <p>My questoin is:
    Can my function <strong>KillThread</strong> kill a thread correctly? If not, what should I do to stop the thead?</p>