コード例 #1
0
        void ChangeStatus(TcpConnectionStatus newStatus)
        {
            if (status == newStatus)
            {
                return;
            }

            status = newStatus;

            logger.Info($"{nameof(TcpClient)} status changed to {newStatus}");

            configuration.SynchronizeSafe(() => {
                ClientStatusChangedEventArgs args = new ClientStatusChangedEventArgs(newStatus);
                try
                {
                    OnStatusChanged(args);
                }
                catch (Exception ex)
                {
                    Logger.Error($"Unhandled exception on {this.GetType().Name}.{nameof(OnStatusChanged)}: {ex}");
                }
                try
                {
                    OnStatusChangedEvent?.Invoke(args);
                }
                catch (Exception ex)
                {
                    Logger.Error($"Unhandled exception on {this.GetType().Name}.{nameof(OnStatusChangedEvent)}: {ex}");
                }
            }, logger);
        }
コード例 #2
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}");
            }
        }