timer logic

Login to reply to this topic.
Thu, 2008-08-28 11:18
Joined: 2007-07-31
Forum posts: 159

Hi all,

i want to create a timer which would be calling a function on a variable interval of time.

i want the following type of code.I dont say that it is working code but i want the code of this type.

int timeinterval = 30;
CMyTimer *timer = new CMyTimer ();
void main()
{

timer->Create(TimerFunction);

// This function will call the TimerFunction function after 30 ms
timer->SetTimeInterval(timeinterval ) //timeinterval  in mili seconds

}
void TimerFunction()
{
    timeinterval +=timeinterval ;
    timer->SetTimeInterval(timeinterval )
}

Please help me...

can i use CActive derived class and over load Run() function but i dont know to use in this manner.So i request you to please give me the code working correctly in symbian C++ like this.

Thank you vey much in advance...
Brajesh Kumar...


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++


Thu, 2008-08-28 11:59
Joined: 2008-06-23
Forum posts: 85
Re: timer logic

If the callback interval won't change then you should take a look at CPeriodic, it might save you from reinventing the wheel Eye-wink

Thu, 2008-08-28 12:48
Joined: 2007-07-31
Forum posts: 159
Re: timer logic

But the CPeriodic call a callback function in every fixed interval of time , but i want the callback function to be called after diffrent intervals.And we can give that interval only when we create the CPeriodic object .


Life is too short ! so do as many good things as you can do...
Brajesh Kumar...
Beginner in Symbian C++

Thu, 2008-08-28 13:00
Joined: 2008-06-23
Forum posts: 85
Re: timer logic

Then you should derive your class from CTimer and implement the RunL() method. This way you can start the timer by calling e.g. After(), and you can also issue another request with a different interval from RunL().

Thu, 2008-08-28 13:07
Joined: 2003-12-05
Forum posts: 672
Re: timer logic

RTFM: CDeltaTimer...

Thu, 2008-08-28 14:27
Joined: 2004-11-29
Forum posts: 1233
Re: timer logic

CDeltaTimer sounds a bit overkill to me...

I'd choose a normal CTimer-derived class that from the RunL call a callback, and then call "After" with the return value of the callback, or stopping if return value is negative (error)

  • Login to reply to this topic.