private void Timer_Callback(object o) { lock (_locker) { try { //Consulto el estado de la conexión bool _isConnected = GetConnectionState(); //Si hay cambio en el estado if (!(_wasConnected == _isConnected)) { //Lanzo el evento ConnectionStateChangedEventArgs e = new ConnectionStateChangedEventArgs(); e.IsConnected = _isConnected; this.OnConnectionStateChanged(e); } _wasConnected = _isConnected; } catch (Exception ex) { ErrorEventArgs errorArgs = new ErrorEventArgs(); errorArgs.CustomeError = ex; this.OnErrorOccurred(errorArgs); } } }
protected virtual void OnErrorOccurred(ErrorEventArgs e) { if (ErrorOccurred != null) { ErrorOccurred(this, e); } }