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.
but I want to switch on iterative loop( while or do.....while) to make it work every time I click a push button (green) to start the acquisition and we'll stop it with the red push button but when I tried with iterative loop it doesnt work & the program crashes
I send you an overview of interface & program I know it contains a lot of mistakes but I'm new to LabWindows