public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.action_scan: dataHandler.LoadDeviceInfoList(); return(true); case Resource.Id.action_add: ui.ShowDialog(GUI_Handler.DialogChoice.INPUT_TEXT); new Thread(() => { while (ui.GetDialogState(GUI_Handler.DialogChoice.INPUT_TEXT)) { ; } if (ui.GetInputTextValue() != "") { dataHandler.AddStreamLink(ui.GetInputTextValue()); ui.FillRtspListView(dataHandler.GetStreamLinkList()); } }).Start(); return(true); } return(base.OnOptionsItemSelected(item)); }
public async void LoadDeviceInfoList() { SsdpDeviceLocator deviceLocator = new SsdpDeviceLocator(); List <string> tempDeviceInfoList = new List <string>(); var foundDevicesTask = Task.Run(() => deviceLocator.SearchAsync(new TimeSpan(0, 0, 5))); string deviceInfo = ""; ui.ShowDialog(GUI_Handler.DialogChoice.LOADING); await Task.Run(() => { while (!deviceLocator.IsSearching || !ui.GetDialogState(GUI_Handler.DialogChoice.LOADING)) { ; } while (deviceLocator.IsSearching && ui.GetDialogState(GUI_Handler.DialogChoice.LOADING)) { ; } if (!ui.GetDialogState(GUI_Handler.DialogChoice.LOADING)) { tempDeviceInfoList = null; return; } tempDeviceInfoList = new List <string>(); foreach (var foundDevice in foundDevicesTask.Result) { try { deviceInfo = ""; var fullDevice = Task.Run(() => foundDevice.GetDeviceInfo()).Result; deviceInfo += fullDevice.FriendlyName + "\n"; deviceInfo += fullDevice.PresentationUrl; if (deviceInfo.Contains("tcp://")) { tempDeviceInfoList.Add(deviceInfo); } } catch (System.AggregateException) { } } if (ui.GetDialogState(GUI_Handler.DialogChoice.LOADING)) { ui.DismissDialog(GUI_Handler.DialogChoice.LOADING); } }); deviceInfoList = tempDeviceInfoList; if (deviceInfoList != null) { this.ui.FillDeviceListView(deviceInfoList); } }