/// <summary> /// Returns and reserves a new port /// </summary> public int GetNextOpenPort() { lock (_lock) { IPortWatcher portWatcher = PortWatcherFactory.CreatePortWatcher(); int newAvailablePort = portWatcher.FindOpenPort(_startPort); _startPort = newAvailablePort + 1; return(newAvailablePort); } }
/// <summary> /// Returns and reserves a new port /// </summary> public int GetNextOpenPort() { IPortWatcher portWatcher = PortWatcherFactory.CreatePortWatcher(); return(portWatcher.FindOpenPort()); }