public async Task <bool> SearchAndConfigure(int[] localUdpPorts, int timeoutS = 20) { _upnpSearcher = new UpnpSearcher(this, d => Configure(d, localUdpPorts)); _pmpSearcher = new PmpSearcher(this, d => Configure(d, localUdpPorts)); _pmpSearcher.SearchAsync().FireAndForget(this); _upnpSearcher.SearchAsync().FireAndForget(this); var sw = Stopwatch.StartNew(); for (; ;) { await Task.Delay(10); if (_succeeded) { return(true); } if (sw.Elapsed.TotalSeconds > timeoutS) { return(false); } } }