/// <summary> /// Async call 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="token">The cancellation token of when the operation should stop waiting for an event.</param> /// <returns>A task representing the operation of getting the structure that contains the result of the waiting operation</returns> public ValueTask <WaitForEventResult> WaitForEventAsync(int pinNumber, PinEventTypes eventTypes, CancellationToken token) { 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.WaitForEventAsync(logicalPinNumber, eventTypes, token)); }
/// <summary> /// Async call 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="token">The cancellation token of when the operation should stop waiting for an event.</param> /// <returns>A task representing the operation of getting the structure that contains the result of the waiting operation</returns> public virtual ValueTask <WaitForEventResult> WaitForEventAsync(int pinNumber, PinEventTypes eventTypes, CancellationToken token) { 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.WaitForEventAsync(logicalPinNumber, eventTypes, token)); }