Best way to add a delay in a loop?


In a console app, running on either windows or Linux, I have a complex loop that polls remote devices using RS232/RS485. I want to delay the loop slightly, but do not want to interfere with any interrupts that may occur. I thought of using a loop within the major loop that would wait for a timer to expire which would toggle a boolean variable.

What is the best way to do this? I was going to use a timer to control the approximate delay, but wondering what is best to put in the sub loop? A do nothing loop is not a good idea, so what should go in there? A NoOp?


Do until x = y
… a bunch of code
… more code

    Do Until DelayLoop = True
    //  What is best to put here?



This is what DoEvents is for. Yielding in a console app for a certain amount of time.