public async Task <bool> Connect(CancellationToken token) { return(await Task <bool> .Run(() => { try { _focuser = GetFocuser(true); Connected = true; if (Connected) { Initialize(); RaiseAllPropertiesChanged(); } } catch (ASCOM.DriverAccessCOMException ex) { Utility.Utility.HandleAscomCOMException(ex); } catch (System.Runtime.InteropServices.COMException ex) { Utility.Utility.HandleAscomCOMException(ex); } catch (Exception ex) { Logger.Error(ex); Notification.ShowError("Unable to connect to focuser " + ex.Message); } return Connected; })); }
public void SetupDialog() { if (HasSetupDialog) { try { bool dispose = false; if (_focuser == null) { _focuser = GetFocuser(false); dispose = true; } _focuser.SetupDialog(); if (dispose) { _focuser.Dispose(); _focuser = null; } } catch (Exception ex) { Logger.Error(ex); Notification.ShowError(ex.Message); } } }
public void Disconnect() { Connected = false; _focuser?.Dispose(); _focuser = null; }