File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,14 +105,7 @@ public MyApplicationContext()
105105
106106 notifyIcon . ContextMenuStrip = contextMenu ;
107107
108- var radios = Radio . GetRadiosAsync ( ) . GetResults ( ) ;
109- bluetoothRadio = radios . FirstOrDefault ( radio => radio . Kind == RadioKind . Bluetooth ) ;
110- if ( bluetoothRadio != null )
111- {
112- bluetoothRadio . StateChanged += BluetoothRadio_StateChanged ;
113- }
114-
115-
108+ InitializeBluetoothRadioAsync ( ) ;
116109 FindBleController ( ) ;
117110
118111 UpdateTimer = new Timer ( ) ;
@@ -126,6 +119,23 @@ public MyApplicationContext()
126119 DiscoverTimer . Start ( ) ;
127120 }
128121
122+ private async void InitializeBluetoothRadioAsync ( )
123+ {
124+ try
125+ {
126+ var radios = await Radio . GetRadiosAsync ( ) ;
127+ bluetoothRadio = radios . FirstOrDefault ( radio => radio . Kind == RadioKind . Bluetooth ) ;
128+ if ( bluetoothRadio != null )
129+ {
130+ bluetoothRadio . StateChanged += BluetoothRadio_StateChanged ;
131+ }
132+ }
133+ catch ( Exception e )
134+ {
135+ LogError ( e ) ;
136+ }
137+ }
138+
129139 private void CheckSoftwareUpdate ( )
130140 {
131141 try
You can’t perform that action at this time.
0 commit comments