AcTools.Processes.TrickyStarter.WaitUntilGameAsync C# (CSharp) Method

WaitUntilGameAsync() public method

public WaitUntilGameAsync ( CancellationToken cancellation ) : Task
cancellation System.Threading.CancellationToken
return Task
        public async Task WaitUntilGameAsync(CancellationToken cancellation) {
            if (_launcherProcess != null) {
                await _launcherProcess.WaitForExitAsync(cancellation);
                _launcherProcess.Dispose();
                _launcherProcess = null;
            }

            for (var i = 0; i < 10; i++) {
                _gameProcess = Process.GetProcessesByName(AcsName.ApartFromLast(".exe", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (_gameProcess != null) break;
                await Task.Delay(2500, cancellation);
            }

            await Task.Delay(2500, cancellation);
            _gameProcess = Process.GetProcessesByName(AcsName.ApartFromLast(".exe", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
        }