/// <summary> /// Raises the <see cref="Interrupt"/> event. /// </summary> /// <param name="sender">The <see cref="InterruptInput"/> object that raised the event.</param> /// <param name="value"><b>true</b> if the the value received from the interrupt is greater than zero; otherwise, <b>false</b>.</param> protected virtual void OnInterruptEvent(InterruptInput sender, bool value) { if (this.Interrupt == null) { return; } if (this.SynchronousUnsafeEventInvocation) { try { this.Interrupt(sender, value); } catch { } } else { if (this.onInterrupt == null) { this.onInterrupt = new InterruptEventHandler(this.OnInterruptEvent); } if (Program.CheckAndInvoke(this.Interrupt, this.onInterrupt, sender, value)) { this.Interrupt(sender, value); } } }
private void Int_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e) { if (e.Edge == GpioPinEdge.FallingEdge) { lock (_socket.LockI2c) { _mux2.Read(_channelValue); } InterruptEventHandler intEvent = InterruptDetected; intEvent(this, new InterruptEventArgs((Byte)(_channelValue[0] >> 4))); } }
/// <summary> /// Raises the <see cref="Interrupt"/> event. /// </summary> /// <param name="sender">The <see cref="InterruptInput"/> object that raised the event.</param> /// <param name="value"><b>true</b> if the the value received from the interrupt is greater than zero; otherwise, <b>false</b>.</param> protected virtual void OnInterruptEvent(InterruptInput sender, bool value) { InterruptEventHandler handler = _interruptHandler; if (handler == null) { return; } if (SynchronousUnsafeEventInvocation) { try { handler(sender, value); } catch { } } else { if (Program.CheckAndInvoke(handler, handler, sender, value)) { handler(sender, value); } } }