Beispiel #1
0
        /// <summary>
        /// Performs connect operation on bluetooth.
        /// Catches any exceptions thrown.
        /// Displays result/exception to the user
        /// </summary>
        /// <returns>Task to be awaited on</returns>
        private async Task ConnectToBT()
        {
            try
            {
                ConnectText = "Connecting...";
                await _btManager.ConnectAsync(SelectedDevice.HostName);

                ErrorMessage = IsConnected ? "Connected successfully" : "Failed to connect!";
                RaisePropertyChanged(() => IsConnected);
            }
            catch (Exception ex)
            {
                // catch any exception and display it
                ErrorMessage = ex.Message;
            }
            finally
            {
                ConnectText = "Connect";
            }
        }