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}"); } }
protected virtual void OnStatusChanged(RpcClientStatusChangedEventArgs args) { }