src/vs/workbench/api/node/extHostTunnelService.ts/ExtHostTunnelService/$registerCandidateFinder
class ExtHostTunnelService:	async $registerCandidateFinder(enable: boolean): Promise<void> {
		if (enable && this._candidateFindingEnabled) {
			// already enabled
			return;
		}
		this._candidateFindingEnabled = enable;
		// Regularly scan to see if the candidate ports have changed.
		let movingAverage = new MovingAverage();
		let oldPorts: { host: string; port: number; detail?: string }[] | undefined = undefined;
		while (this._candidateFindingEnabled) {
			const startTime = new Date().getTime();
			const newPorts = (await this.findCandidatePorts()).filter(candidate => (isLocalhost(candidate.host) || isAllInterfaces(candidate.host)));
			this.logService.trace(`ForwardedPorts: (ExtHostTunnelService) found candidate ports ${newPorts.map(port => port.port).join(', ')}`);
			const timeTaken = new Date().getTime() - startTime;
			movingAverage.update(timeTaken);
			if (!oldPorts || (JSON.stringify(oldPorts) !== JSON.stringify(newPorts))) {
				oldPorts = newPorts;
				await this._proxy.$onFoundNewCandidates(oldPorts);
			}
			await (new Promise<void>(resolve => setTimeout(() => resolve(), this.calculateDelay(movingAverage.value))));
		}
	}