コード例 #1
0
        public void Purge()
        {
            _needsPurge = false;
            while (CommandQueue.Any())
            {
                CommandQueue.TryDequeue(out var dummy);
            }

            _uiContext.Send(
                state =>
            {
                CommandList.Clear();
            }, null);

            _stopWatch.Reset();
        }
コード例 #2
0
ファイル: EngineProcess.cs プロジェクト: wesIdeal/ChessLib
        private void BeginMessageQueue()
        {
            var exit = false;

            WriteDebugInformation("Starting message queue.");
            while (!exit)
            {
                var waits = EngineCommandQueue.CommandIssuedEvents;
                if (_currentCommand != null && _currentCommand is AwaitableCommandInfo awaitableCommand)
                {
                    var handle     = awaitableCommand.ResetEvent;
                    var waitResult = WaitHandle.WaitAny(new WaitHandle[] { handle, EngineCommandQueue.InterruptIssued });
                    if (waitResult == 1)
                    {
                        awaitableCommand.ResetEvent.Set();
                    }
                    awaitableCommand.Dispose();
                    awaitableCommand = null;
                    _currentCommand  = null;
                }
                else
                {
                    if (!EngineCommandQueue.Any())
                    {
                        var waitResult = WaitHandle.WaitAny(waits);
                    }
                    else
                    {
                        EngineCommandQueue.TryDequeue(out var commandToIssue);
                        _currentCommand = commandToIssue;
                        Send(commandToIssue.ToString());
                        exit = commandToIssue.CommandSent == AppToUCICommand.Quit;
                    }
                }
            }
        }