static Tuple<Process, int> StartOnFirstFreePort(Settings settings) { do { try { Console.WriteLine("Trying to start {0} {1} on port {2}", settings.Executable, settings.Arguments(settings), settings.Port); var process = StartProcess(settings); Console.WriteLine("Started [{0}] {1} on port {2}", process.Id, settings.Executable, settings.Port); settings.Started(process, settings); return new Tuple<Process, int>(process, settings.Port); } catch (Exception ex) { Console.WriteLine(ex.Message); } settings = settings.TryNextPort(); } while (true); }
static Tuple <Process, int> StartOnFirstFreePort(Settings settings) { do { try { Console.WriteLine("Trying to start {0} {1} on port {2}", settings.Executable, settings.Arguments(settings), settings.Port); var process = StartProcess(settings); Console.WriteLine("Started [{0}] {1} on port {2}", process.Id, settings.Executable, settings.Port); settings.Started(process, settings); return(new Tuple <Process, int>(process, settings.Port)); } catch (Exception ex) { Console.WriteLine(ex.Message); } settings = settings.TryNextPort(); }while (true); }