Are you asking for a loop which will run basically every n ticks? This sounds like a Timer. There are a couple of timer's in the BCL. A timer for servers or one for Window Forms.
You can use them along these lines. The following is psuedo code and meant to show generally how this is done. In other words it probably won't compile if you just copy and paste.
public class RepeatingTask
{
public MyObjectState _objectState;
public RepeatingTask(Timespan interval)
{
Timer timer=new Timer(Timer_Tick); //This assumes we pass a delegate. Each timer is different. Refer to MSDN for proper usage
timer.Interval=interval;
timer.Start();
}
private DateTime _lastFire;
private void Timer_Tick()
{
DateTime curTime=DateTime.Now();
DateTime timeSinceLastFire = curTime-lastFireTime;
_lastFire=DateTime.Now(); //Store when we last fired...
accumulatedtime+=timeSinceLastFire
while(accumulatedtime>=physicsInterval)
{
Update(physicsInterval);
accumulated-=physicInterval;
}
}
}
You can also use a closure to wrap up your state of the method which the timer is defined in.
Edit
I read the article and I understand the issue; however, you could still use a timer, but you need to as he indicates set your function up to call the engines for each interval you set your physics engine to.
Are you using WPF they have some events I believe which get fired at steady rates for doign animations.
Edit
I updated my code sample to show you my interpretation but basically what you do is define an interval for your physics engine, and then what you need to do on each pass through your "Loop / Timer whatever" is determine how much real time passed since the last iteration. You then store that delta in an Accumalator, which you will use to count down until you've called your physics engine for all the intervals that you missed since you last called.
What I struggle with is if using a timer here is better, then having a dedidicated thread sleeping, or some other implementation.