本文整理汇总了C#中Thread.Any方法的典型用法代码示例。如果您正苦于以下问题:C# Thread.Any方法的具体用法?C# Thread.Any怎么用?C# Thread.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread.Any方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectMove
//выбирает ход для выбранного игрока с глубиной не более maxDeep
public Step SelectMove(Player p, int maxDeep, Board board)
{
Count = 0;
_maxDeep = maxDeep;
_threadsResults.Clear();
var nBoard = new Board(board);
var game = new Game(nBoard);
var moves = game.getAllLegalMoves(p);
var b = moves.Batch(moves.Count/ThreadCount).ToList();
var thraads = new Thread[b.Count];
var n = 0;
foreach (var curMoves in b)
{
var args = new TheadArg
{
board = new Board(board),
startPlayer = p,
steps = curMoves.ToList()
};
var thread = new Thread(Process) {IsBackground = true};
thread.Start(args);
thraads[n++] = thread;
}
while (thraads.Any(x => x.IsAlive))
{
Thread.Sleep(100);
}
var res = _threadsResults.MaxBy(x => x.Score);
return res.Step;
}