/// <summary> /// Disposes of resources. /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects). if (ChessEngineController != null) { ChessEngineController.Dispose(); ChessEngineController = null; } } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. _disposedValue = true; } }
/// <summary> /// Sends an asynchronous command to the chess engine to enable UCI mode. /// When successful the <see cref="ChessEngineOptions"/> property will contain /// the options that the engine supports. /// </summary> /// <remarks><see cref="UciCommand"/> for more information.</remarks> private void SetUciMode() { using (var uciCommand = _commandFactory.CreateCommand <UciCommand>()) { var uciCommandTask = uciCommand.SendAsync(); uciCommandTask.Wait(uciCommand.CommandResponsePeriod); if (uciCommand.CommandResponseReceived) { ChessEngineOptions = uciCommand.Options; UciModeComplete = true; } else { // Initialization wasn't completed by the chess engine within the specified // time period so kill the process. Logger.LogInformation("Killing the chess engine process"); ChessEngineController.KillEngine(); Logger.LogCritical(Messages.ChessEngineDidntInitialize); throw new ChessterEngineException(Messages.ChessEngineDidntInitialize); } } }