private void btnRefresh_Click(object sender, RoutedEventArgs e) { try { Application.Current.Dispatcher.BeginInvoke((Action)(() => { gridError.Visibility = Visibility.Collapsed; })); txtError.Text = ""; _selectedService = null; gridInteract.Visibility = Visibility.Collapsed; gridObserve.Visibility = Visibility.Collapsed; if (_coapManager.GetRequest()) { observeables.Clear(); foreach (var item in _coapManager.ObserveServices) { observeables.Add(item); } setLVSource(); } else { Application.Current.Dispatcher.BeginInvoke((Action)(() => { gridError.Visibility = Visibility.Visible; })); Application.Current.Dispatcher.BeginInvoke((Action)(() => { txtError.Text = "Unable to retrieve IoT Services."; })); lvServices.ItemsSource = null; } } catch (Exception) { Application.Current.Dispatcher.BeginInvoke((Action)(() => { gridError.Visibility = Visibility.Visible; })); Application.Current.Dispatcher.BeginInvoke((Action)(() => { txtError.Text = "Unable to retrieve IoT Services."; })); lvServices.ItemsSource = null; } }
private bool TestConnection() { COAPManager _coap = new COAPManager("10.0.1.2"); return(_coap.GetRequest()); }