/// <summary> /// Blocks execution until an event of type eventType is received or a cancellation is requested. /// </summary> /// <param name="pinNumber">The pin number in the controller's numbering scheme.</param> /// <param name="eventTypes">The event types to wait for.</param> /// <param name="cancellationToken">The cancellation token of when the operation should stop waiting for an event.</param> /// <returns>A structure that contains the result of the waiting operation.</returns> public WaitForEventResult WaitForEvent(int pinNumber, PinEventTypes eventTypes, CancellationToken cancellationToken) { int logicalPinNumber = GetLogicalPinNumber(pinNumber); if (!_openPins.Contains(logicalPinNumber)) { throw new InvalidOperationException("Can not wait for events from a pin that is not open."); } return(_driver.WaitForEvent(logicalPinNumber, eventTypes, cancellationToken)); }
/// <summary> /// Blocks execution until an event of type eventType is received or a cancellation is requested. /// </summary> /// <param name="pinNumber">The pin number in the controller's numbering scheme.</param> /// <param name="eventTypes">The event types to wait for.</param> /// <param name="cancellationToken">The cancellation token of when the operation should stop waiting for an event.</param> /// <returns>A structure that contains the result of the waiting operation.</returns> public virtual WaitForEventResult WaitForEvent(int pinNumber, PinEventTypes eventTypes, CancellationToken cancellationToken) { if (!IsPinOpen(pinNumber)) { throw new InvalidOperationException($"Can not wait for events from pin {pinNumber} because it is not open."); } int logicalPinNumber = GetLogicalPinNumber(pinNumber); return(_driver.WaitForEvent(logicalPinNumber, eventTypes, cancellationToken)); }