You should know that this won't be deterministic, your program will have the priority that the OS will give to it and therefore timers can change slightly their final results.
Apart of that, if you would need to do some parallel tasks during that "timer" or sleep call, you would not be able to do it.
Then things can grow up more difficult...
What typically it is being done in the automotion world when you program a PLC or so, is to establish an infinite while loop.
Those loops take a specific amount of time (typically 10ms).
Then all the code happens there and you are in each cycle checking all the conditions and reacting to them to get the desired result... something like:
while (true)
{
if (move_activated)
{
if (position < destination)
{
move_neg = false;
move_pos = true;
}
else if (position > destination)
{
move_pos = false;
move_neg = true;
}
else
{
move_pos = false;
move_neg = false;
}
if (bTimeCount)
{
if (previous_bTimeCount = false)
{
StartTime = GetTime();
}
CurrentTime = GetTime();
if (CurrentTime - StartTime > DesiredWaitingTime)
{
bTimeCount = false;
}
bPreviousTimeCount = btimeCount;
}
sleep(10); }
That was a small pseudocode snippet that can give you some advice in how to proceed.
See that in case you want to process a time and meanwhile you want to control other things, what is done in the automation world is preparing a base cycle of x millisencods and react to the world conditions with that time base.
Again, you can't trust it to be real each cycle, this is what makes industrial controllers special, they are deterministic.
And let me ask you one question... How do you plan to connect the software to the real world? I mean which will be the interface to the inputs and outputs?
Good luck!