本文整理汇总了C#中Engine.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.Dispose方法的具体用法?C# Engine.Dispose怎么用?C# Engine.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connect
/// <summary>
/// Connects to the configured backup archive
/// </summary>
static void Connect()
{
engine = new Engine()
{
Connection = new Connection(connectionString),
Canceler = canceler.Token
};
try
{
engine.OnProgress += HandleProgress;
engine.OnError += HandleError;
engine.OpenArchive(archiveName, password);
if (cleanupSessions)
{
Console.Write(" Deleting existing restore sessions...");
foreach (var session in engine.Archive.Restores)
engine.DeleteRestore(session);
Console.WriteLine("done.");
}
}
catch
{
engine.Dispose();
throw;
}
}
示例2: processBoard
private static void processBoard(string[] boardParts, TextWriter output, NodeCounter counter)
{
// check params first
if (boardParts.Length < 2) {
output.Write("Error: not enough arguments supplied.\t");
return;
}
Chess[,] board = parseBoard(boardParts[0]);
if (board == null) {
output.Write("Error: board not recognized.\t");
return;
}
Chess mover = parseMover(boardParts[1]);
if (mover == Chess.AVAILABLE) {
output.Write("Error: mover not recognized.\t");
return;
}
bool wld = false, warmup = false;
int mid = 0;
for (int i = 2; i < boardParts.Length; i++) {
string option = boardParts[i].ToUpper();
if (option == "WLD")
wld = true;
else if (option == "WARMUP")
warmup = true;
else if (option.StartsWith("MID")) {
Int32.TryParse(option.Substring(3), out mid);
if (mid < 0) mid = 0;
}
}
Engine.clearCache();
Engine engine = new Engine();
engine.setBoard(board);
DateTime timeStart = DateTime.Now;
SearchResult res = (mid == 0) ? engine.solveExact(mover, wld) : engine.solve(mover, mid, false);
TimeSpan timeSpan = DateTime.Now - timeStart;
SearchStats stats = engine.getSearchStats();
engine.Dispose();
output.Write(resultString(res, wld, mid));
output.Write("\t");
output.Write(moveString(res));
output.Write("\t");
output.Write(nodesString(stats.EvaluationCount));
output.Write("\t");
output.Write(npsString(timeSpan, stats.EvaluationCount));
output.Write("\t");
output.Write(timeSpan.TotalSeconds.ToString("0.0") + " s");
output.Write("\t");
if (!warmup) {
counter.totalNodes += stats.EvaluationCount;
counter.totalTime += timeSpan;
}
}