private async Task _HandleListClickAsync(object sender, AdapterView.ItemClickEventArgs args) { RunOnUiThread(() => { // Show the loading... symbol. _possibleListenerDevices.Visibility = Android.Views.ViewStates.Gone; _emptyListenerDevices.Visibility = Android.Views.ViewStates.Gone; _connectingToDevice.Visibility = Android.Views.ViewStates.Visible; _connectingText.Text = "Connecting to device..."; }); // Select the device var position = args.Position; var item = ((DeviceRowAdapter)_possibleListenerDevices.Adapter).GetItem(position); // Set the Tcp Connection up. That way you don't actually need to wait // for a message to be sent to start sending messages from the "server". _StartConnectionIntent(item.IpAddress, item.Port); RunOnUiThread(() => { // Communicate your public key... _connectingText.Text = "Generating Public/Private Key..."; }); var publicPrivate = Crypto.GetPublicPrivateKey(); _privateKey = publicPrivate[1]; var publicKey = PublicKey.FromRsaParameters(publicPrivate[0]); // Gets a password to use var password = Crypto.CreateUniquePasswordForIdentifyingConnectedDevice(5); var aes = Crypto.CreateAesKeyIV(password); var encrypted = Crypto.EncryptWithAesKeyIV(publicKey.ToJson(), aes); RunOnUiThread(() => { _ShowModalWithPassword(password); // Turn off the loading... symbol. _disconnectButton.Visibility = Android.Views.ViewStates.Visible; _possibleListenerDevices.Visibility = Android.Views.ViewStates.Visible; _emptyListenerDevices.Visibility = Android.Views.ViewStates.Visible; _connectingToDevice.Visibility = Android.Views.ViewStates.Gone; _connectingText.Text = ""; }); // Send to the Tcp Handler to let the Desktop know we are doing this! _SendSharedPasscodeAndStartConversationIntent(password, encrypted + "<BEG>"); }