public void Stop() { try { cancel(); #if UseTask // // Block GUI requested stops briefly, allowing the search // statistics to be written before this request completes. // const Int32 stopTimeoutMS = 5000; if (CancelTimer is not null) { CancelTimer.Change(stopTimeoutMS, Timeout.Infinite); } FinishTask?.Wait(); // //[Note]The old CancellationToken must be recycled after cancel() has been called. // freeCancellationToken(); #endif } catch (AggregateException aex) { var ex = aex.Flatten(); //LogLine(ex.ToString()); throw ex; } }
public void Ponderhit() { // //[Note]This command should only occur while a Ponder Search is in progress, after its // "go ponder" command has been issued. It indicates that the previously hypothetical // move was in fact made by the User; and that the search may continue normally. // // The sequence preceding this "ponderhit" is as follows: // // When in Ponder Mode, the Engine returns a Ponder Move as well as the Best Move when // completing a search. // // The GUI issues a "go ponder" command, which includes the Ponder Move as part of the // starting position for the search; and the command also includes Time Controls to be // used in the event that a "ponderhit" command is subsequently handled here. // // If the Opponent chooses some move other than the Ponder Move, the GUI simply issues // a "stop" command to cancel the Ponder Search. Then the GUI will start a new search // from the correct starting position. Note that this will not be a Ponder Search. // if (Bound.IsPonder) { Bound.IsPonder = false; // Cease to Ponder var nTimeoutMS = Bound.MoveTime(ExpectedMovesToGo); if (nTimeoutMS != Timeout.Infinite) { #if UseTask Debug.Assert(CancelTimer is not null, "Null CancelTimer Instance"); //[Note]Timeout.Infinite declares that the CancelTimer should not restart! CancelTimer.Change(nTimeoutMS, Timeout.Infinite); #endif } } }