I am writing a chess game that allows you to compete with two programs, the player needs to write a DLL and set a function to tell the main application in which this player will move in the next, suppose that the function looks like
public static void MoveNext(out int x, out int y, out int discKind);
In a chess game application, I start a new thread to call a function that the DLL player has discovered to get where it will move in a turn, and I start a timer to prevent player timeouts
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) {
My call: Can my KillThread function correctly kill the thread? If not, what should I do to stop thead?
multithreading c #
Carlos Liu
source share