public void ThreadEnd(int ctid) { if (ctid > 0) { Debug.Assert(ctid == CurrentTid); } if (!MChessChess.TaskEnd()) { if (MChessChess.IsBreakingDeadlock()) { BreakDeadlockMode = true; MChessChess.WakeNextDeadlockedThread(false, false); } else { ChessDetach(); } } }