Creating delay loop in C++

Do you have an overall diagram of what you want to achieve? Is it part of a bigger system?

Because the answer will be different as I dont believe in analog or digital are superior. Whatever fit best is the superior solutio