Skip to content

RTimer limit and how to overcome it.

In Symbian C++, RTimer is the timer class to fire timers after specific duration or at specific time. The problem with RTimer is that there is a limit on the duration.
The in parameter for RTimer::After is TTimeIntervalMicroseconds32 which mean mean 2^31 micro seconds is the limit. This would translate to approximately 2147.483648 seconds or 35.791394133 minutes. So RTimer::After cannot be used for anything more than 35 minutes.

So now the challenge is to set a timer for an hour. Let’s see what options do we have:

1. Use RTimer::At in 30 mins steps. This requires that there needs to be special code for the it and other times like say 85 mins cannot be set.

2. Use RTimer::After to set the timer to expire after the required duration. Here the catch is, if there are  changes in time zone the RTimer will abort and you will have to figure out the remaining duration to set the next After timer. I think its more tricky to figure out the remaining time.

So I have coded a generic class to set timers for longer than the limit of RTimer. I have uploaded the code in Google code. The CTimerX in minute mode can be set for 2^31 minutes , which is approx 35791394.13 hours or 1491308.089 days. This should suffice for most practical applications.

Do check the xwerks project in Google code which has the ExtendedTimer demo, showcasing the use of CTimerX class.

For more Info for Symbian Timer issues check this wiki article :