CreatePortWatcher() public static method

public static CreatePortWatcher ( ) : IPortWatcher
return IPortWatcher
示例#1
0
        /// <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);
            }
        }
示例#2
0
        /// <summary>
        /// Returns and reserves a new port
        /// </summary>
        public int GetNextOpenPort()
        {
            IPortWatcher portWatcher = PortWatcherFactory.CreatePortWatcher();

            return(portWatcher.FindOpenPort());
        }