Example #1
0
        void ChangeStatus(RpcClientStatus newStatus)
        {
            if (Status == newStatus)
            {
                return;
            }
            logger.Debug($"Changed status from {Status} to {newStatus}");
            RpcClientStatusChangedEventArgs args = new RpcClientStatusChangedEventArgs(this, Status, newStatus);

            Status = newStatus;

            try
            {
                OnStatusChanged(args);
            }
            catch (Exception e)
            {
                logger.Error($"Unhandled exception on {this.GetType().Name}.{nameof(OnStatusChanged)}: {e}");
            }

            try
            {
                OnStatusChangedEvent?.Invoke(args);
            }
            catch (Exception e)
            {
                logger.Error($"Unhandled exception on {this.GetType().Name}.{nameof(OnStatusChangedEvent)}: {e}");
            }
        }
Example #2
0
 internal RpcClientStatusChangedEventArgs(RpcTcpClient client, RpcClientStatus oldStatus, RpcClientStatus newStatus)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     this.Client    = client;
     this.OldStatus = oldStatus;
     this.NewStatus = newStatus;
 }