public async void SearchLAN() { this.discoveredTivos.Clear(); try { AddDebugText("Searching..."); AddDebugText(""); Mouse.OverrideCursor = Cursors.Wait; var dnsAnswers = await MDnsClient.CreateAndResolveAsync(dnsProtocol); if (dnsAnswers != null) { var answersSubscription = dnsAnswers .Select(HandleDnsAnswer) .Where(x => x != null) .ObserveOnDispatcher() .Subscribe(x => this.discoveredTivos.Add(x)); await Task.Delay(TimeSpan.FromSeconds(3)); answersSubscription.Dispose(); } } finally { AddDebugText("Search finished"); Mouse.OverrideCursor = null; } }
private async Task <bool> DiscoverTivos() { var dnsAnswers = await MDnsClient.CreateAndResolveAsync(dnsProtocol); if (dnsAnswers != null) { var answersSubscription = dnsAnswers .Select(HandleDnsAnswer) .Where(x => x != null) .ObserveOnDispatcher() .Subscribe(x => this.discoveredTivos.Add(x)); await TaskEx.Delay(TimeSpan.FromSeconds(3)); answersSubscription.Dispose(); return(true); } return(false); }