private static int FindFreePort()
{
for (int i = 0; i < 10; i++)
{
int port = RandomPort();
if (!_usedPorts.Contains(port) && !IsBusy(port))
return port;
}
throw new InvalidOperationException("Unable to find a free port after 10 tries");
}
private static int RandomPort()