private static async Task Go() { var menuOption = await Menu(); switch (menuOption) { case 1: try { await _DeviceConnectionExample.InitializeTrezorAsync(); await DisplayDataAsync(); _DeviceConnectionExample.Dispose(); GC.Collect(); await Task.Delay(10000); } catch (Exception ex) { Console.Clear(); Console.WriteLine(ex.ToString()); } Console.ReadKey(); break; case 2: Console.Clear(); DisplayWaitMessage(); _DeviceConnectionExample.StartListening(); break; } }
#pragma warning restore IDE0060 // Remove unused parameter #pragma warning restore IDE0051 // Remove unused private members #endregion #region Private Methods private async Task DisplayDataAsync(bool initialize) { TheProgressRing.IsActive = true; try { if (initialize) { await _DeviceConnectionExample.InitializeTrezorAsync(); } var readBuffer = await _DeviceConnectionExample.WriteAndReadFromDeviceAsync(); if (readBuffer == null) { throw new Exception("No data returned"); } DevicePanel.DataContext = _DeviceConnectionExample.TrezorDevice.ConnectedDeviceDefinition; OutputBox.Text = string.Join(' ', readBuffer); } catch (Exception ex) { _ = await new MessageDialog(ex.Message, "Error").ShowAsync(); } TheProgressRing.IsActive = false; }
private static async Task GoAsync() { var menuOption = await MenuAsync().ConfigureAwait(false); switch (menuOption) { case 1: try { await _DeviceConnectionExample.InitializeTrezorAsync().ConfigureAwait(false); await DisplayDataAsync().ConfigureAwait(false); _DeviceConnectionExample.Dispose(); GC.Collect(); await Task.Delay(10000).ConfigureAwait(false); } catch (Exception ex) { Console.Clear(); Console.WriteLine(ex.ToString()); } Console.ReadKey(); break; case 2: Console.Clear(); DisplayWaitMessage(); _DeviceConnectionExample.StartListening(); break; #if !LIBUSB case 3: Console.Clear(); await DisplayTemperature().ConfigureAwait(false); while (true) { await Task.Delay(1000).ConfigureAwait(false); } #endif default: Console.WriteLine("That's not an option"); break; } }
public async override void ViewDidLoad() { base.ViewDidLoad(); LibUsbUsbDeviceFactory.Register(); await TrezorExample.InitializeTrezorAsync(); var buffer = await TrezorExample.WriteAndReadFromDeviceAsync(); var alert = new NSAlert { MessageText = $"Got it! {buffer[0]},{buffer[1]},{buffer[2]}. Warning: Make sure you unplug and replug before trying again.", AlertStyle = NSAlertStyle.Informational }; alert.AddButton("OK"); var returnValue = alert.RunModal(); }
private async Task DisplayDataAsync(bool initialize) { TheProgressRing.IsActive = true; try { if (initialize) { await _DeviceConnectionExample.InitializeTrezorAsync(); } var readBuffer = await _DeviceConnectionExample.WriteAndReadFromDeviceAsync(); DevicePanel.DataContext = _DeviceConnectionExample.TrezorDevice.ConnectedDeviceDefinition; OutputBox.Text = string.Join(' ', readBuffer); } catch { } TheProgressRing.IsActive = false; }