How to wait for a specific period without suspending the app
| Mon, 2005-12-05 08:34 | |
|
Hello,
Is there any way to wait for a period of time with out suspending the application? I know I could do it with some timer class and by implementing some interface. But my waiting task is very trivial and donÂ’t want to add that much overhead of class or interface in my code. So I am just curious to know is there any possibilities to make my app wait for few seconds ( 1 or 2 sec ) without suspending? |
|






Forum posts: 278
Forum posts: 68
Forum posts: 2006
Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant
Forum posts: 68
Forum posts: 78
Have a look at CActiveSchedulerWait class.
To "insert" a pausing into the existing code, you'll have to create the CActiveSchedulerWait somewhere (e.g. in a constructor) and call its Start() when you need to make a pause.
Still, you'll have to use some timer object, but from its callback you can just call iYourSchedulerWait->AsyncStop() and the paused function will be resumed.
I believe it is one of the simplest ways of adding an "async pause" into the existing program
Compilable Symbian Code Examples
Forum posts: 278
Forum posts: 68
Br,
madsum
Forum posts: 78
In fact I meant using some timer together with CActiveSchedulerWait
There is nothing too bad in using nested loops. You should be careful only about calling one AsyncStop() for every Start().
Using only timer is generally better, at least because it is simpler. You would need to add CActiveSchedulerWait if at some point you realize that you need split an existing long function into several steps executed in several ActiveScheduler time slots. If you'll ever have to do it, introducing CActiveSchedulerWait is usually simpler and more reliable than re-engineer logic and actually splitting a long function into several
Compilable Symbian Code Examples