Beispiel #1
0
 public void Open()
 {
     try
     {
         SourceConnection.Open();
         Status = ConnectionStatus.Open;
         Opened?.Invoke(this, EventArgs.Empty);
     }
     catch (Exception)
     {
         Status = ConnectionStatus.Closed;
         OpenFailed?.Invoke(this, EventArgs.Empty);
     }
 }
Beispiel #2
0
        //todo: repair DRY violation

        private async void StartOpenAsync()
        {
            try
            {
                Status = ConnectionStatus.Opening;
                await SourceConnection.OpenAsync(cancelSource.Token);

                Status = ConnectionStatus.Open;
            }
            catch (Exception)
            {
                Status = ConnectionStatus.Closed;
            }

            if (Status == ConnectionStatus.Open)
            {
                Opened?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                OpenFailed?.Invoke(this, EventArgs.Empty);
            }
        }