public override void Start() {
if( _restart_attempts < 0 ) {
throw new Exception("restarted too many times");
}
if( Interlocked.Exchange(ref _first_start, 0) == 1) {
//Compute the interval:
#if BRUNET_SIMULATOR
Random rand = Node.SimulatorRandom;
#else
Random rand = new Random();
#endif
int restart_msec = rand.Next(_MS_RESTART_TIME);
Action<DateTime> torun = delegate(DateTime now) {
//Tell the node to call Start on us:
_linker.LocalNode.EnqueueAction(this);
};
//Schedule a waiting period:
Brunet.Util.FuzzyTimer.Instance.DoAfter(torun, restart_msec, 1000);
}
else {
//Time to finish
FireFinished();
}
}