private async Task connect(String id) { _obd = new ObdCommunication(); _connectButton.Content = "Verbinde OBD..."; disableUserInteraction(); (App.Current as App).Obd = _obd; Boolean successfull = false; successfull = await(App.Current as App).Obd.establishConnection(id); if (successfull) { if (_autoconnect) { ApplicationData.Current.LocalSettings.Values["bluetoothPeer"] = id; } else { ApplicationData.Current.LocalSettings.Values.Remove("bluetoothPeer"); } _bluetoothID = id; Frame.Navigate(typeof(TrackerPage), _routeName); } else //Fehler { ApplicationData.Current.LocalSettings.Values.Remove("bluetoothPeer"); _connectButton.Content = "Verbindung aufbauen"; enableUserInteraction(); _connectButton.IsEnabled = true; var emailErrorDialog = new MessageDialog("Fehler beim Aufbau der OBD Verbindung. Adapter neustarten und erneut versuchen! "); emailErrorDialog.Commands.Add(new UICommand("ok")); await emailErrorDialog.ShowAsync(); } }
//----------------------init-functions-----------------------------------// private void initObd() { _obd = (App.Current as App).Obd; _obdThread = Windows.System.Threading.ThreadPool.RunAsync((source) => { consumptionTracker(); }, WorkItemPriority.High); }