public void Purge() { _needsPurge = false; while (CommandQueue.Any()) { CommandQueue.TryDequeue(out var dummy); } _uiContext.Send( state => { CommandList.Clear(); }, null); _stopWatch.Reset(); }
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; } } } }