Exemplo n.º 1
0
        public Task RunWorms(params string[] wormsArgs)
        {
            return(Task.Factory.StartNew(
                       () =>
            {
                var gameInfo = _wormsLocator.Find();

                var args = string.Join(" ", wormsArgs);
                using (var process = Process.Start(gameInfo.ExeLocation, args))
                {
                    if (process == null)
                    {
                        return;
                    }

                    process.WaitForExit();
                    if (process.ExitCode == 0)
                    {
                        return;
                    }
                }

                _steamService.WaitForSteamPrompt();

                var wormsProcess = Process.GetProcessesByName(gameInfo.ProcessName).FirstOrDefault();
                wormsProcess?.WaitForExit();
            }));
        }
Exemplo n.º 2
0
        private Task <bool> RunWorms(params string[] wormsArgs)
        {
            return(Task <bool> .Factory.StartNew(() =>
            {
                var args = string.Join(" ", wormsArgs);
                using (var process = Process.Start(_wormsLocator.ExeLocation, args))
                {
                    if (process == null)
                    {
                        return false;
                    }

                    process.WaitForExit();
                    if (process.ExitCode == 0)
                    {
                        return true;
                    }
                }

                _steamService.WaitForSteamPrompt();

                var wormsProcess = Process.GetProcessesByName(_wormsLocator.ProcessName).FirstOrDefault();
                wormsProcess?.WaitForExit();

                return wormsProcess != null;
            }));
        }