Why aren’t you just looping the timer instead of adding recursion the called function?
This isn’t recursion. The RPC enables the timer which fires once on a timer thread. When it executes the method, it adds a new timer request which 2 seconds later will call the method again. The reason you may want to do it this way is you may not always want it to repeat or you may only want it to happen once and not call the timer. I appreciate you can stop the timer at any point, or, you can not schedule it again. Either works.
Recursion would be the method calling itself directly such as the following
int factorial(int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}
What’s the difference? The best way to think of it is a queuing of a call so in initiating the timer, it queues a single call and then on it being called, it can decide to queue again, or not. It has advantages over looping indefinitely which may not be the desired outcome.