The easiest way is probably to setup a timer that fires say 4 times/sec and check the state of the digital line in it using the example that you already found. An improvement to the example is to move task configuration and cleaning at the beginning and end of your application, leaving only reading part in the timer callback.
An alternative, more complex method is to setup a callback that fires on the hardware event, something on the line of the example ReadDigChan-ChangeDetectionEvent.