plz help me about CTimeOutTimer..
| Mon, 2005-05-02 04:33 | |
|
hi,
you probably know the periodic example from sdk examples.. whole day i ve worked on adding a new timer which is CTimeOutTimer to this periodic timer... i wanna only make to add this CTimeOutTimer timer and after a duration write hello in the console.Also the priority of CTimeOutTimer must be higher than the CPeriodic timer... This is the code for Cperiodic timer: class TAppRunner { public: TAppRunner(); void NotifyFinished(); // notify an active object has finished void NotifyStarted(); // notify an active object has started // private: TInt iActiveObjects; // count of active objects }; TAppRunner::TAppRunner() { iActiveObjects=0; } void TAppRunner::NotifyStarted() { iActiveObjects++; } void TAppRunner::NotifyFinished() { iActiveObjects--; if (iActiveObjects==0) CActiveScheduler::Stop(); } class CPeriodicRunner : public CBase { public: // construct, add CPeriodic to active scheduler, and start it static CPeriodicRunner* NewL(TInt aTickInterval, TInt aTotalTicks, TAppRunner& aAppRunner); ~CPeriodicRunner(); // destruct and give statistics protected: CPeriodicRunner(TInt aTickInterval, TInt aTotalTicks, TAppRunner& aAppRunner); private: void ConstructL(); // second construction phase // functions for TCallBack protocol static TInt Tick(TAny* aObject); // directly called void DoTick(); // indirectly called private: // constructor parameters TAppRunner& iAppRunner; // notify when started and finished TInt iTotalTicks; // number of ticks requested TInt iTickInterval; // the tick interval in microseconds // things set up by ConstructL TTime iStartTime; // when we were started CPeriodic* iPeriodic; // periodic timer active object // ticks left will be decremented as we go TInt iTicksLeft; // number of ticks before we expire TInt iTimerNumber; // indentifying number for the timer // seed for random delay generator TInt64 iDelaySeed; }; // protected C++ constructor CPeriodicRunner::CPeriodicRunner(TInt aTickInterval, TInt aTotalTicks, TAppRunner& aAppRunner) : iAppRunner(aAppRunner), iTotalTicks(aTotalTicks), iTickInterval(aTickInterval) {} // private second-phase constructor void CPeriodicRunner::ConstructL() { iStartTime.HomeTime(); iPeriodic=CPeriodic::NewL(0); // neutral priority iAppRunner.NotifyStarted(); iTimerNumber = iAppRunner.iActiveObjects; // set idenfifying number for timer iTicksLeft = iTotalTicks; // variable (actually 1 second) delay and interval iPeriodic->Start(iTickInterval,iTickInterval,TCallBack(Tick, this)); } // construct, add CPeriodic to active scheduler, and start it CPeriodicRunner* CPeriodicRunner::NewL(TInt aTickInterval, TInt aTotalTicks, TAppRunner& aAppRunner) { CPeriodicRunner* self=new (ELeave) CPeriodicRunner(aTickInterval, aTotalTicks, aAppRunner); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(); return self; } // destruct and give statistics CPeriodicRunner::~CPeriodicRunner() { TTimeIntervalMicroSeconds elapsedTime; TTime currentTime; // set current time currentTime.HomeTime(); // set currentTime to now // find and show elapsed time & ticks elapsedTime = currentTime.MicroSecondsFrom(iStartTime); // NOTE - Int64() returns a const reference. // GetTInt() is a non const function - hence the need to // copy the returned TInt64. TInt64 a = elapsedTime.Int64(); _LIT(KFormat1,"Periodic timer %d finished: %dus for %d %dus ticks\n"); console->Printf(KFormat1,iTimerNumber,a.GetTInt(),iTotalTicks,iTickInterval); // cancel any outstanding request; delete owned CPeriodic object iPeriodic->Cancel(); delete iPeriodic; // tell app runner we've finished (if we're last, scheduler will stop) iAppRunner.NotifyFinished(); } // private TInt CPeriodicRunner::Tick(TAny* aObject) { ((CPeriodicRunner*)aObject)->DoTick(); // cast, and call non-static function return 1; } // private void CPeriodicRunner::DoTick() { iTicksLeft--; _LIT(KFormat2,"Periodic timer %d: %d ticks done\n"); console->Printf(KFormat2, iTimerNumber, iTotalTicks - iTicksLeft); if(iTicksLeft==0) { delete this; } RandomDelay(iDelaySeed,iTimerNumber); // a random delay to mess up the timing } //////////////////////////////////////////////////////////////// where i must add the decleration of CTimeOutTimer, and where i must call the timeout funtion that write hello in console??? i ve examine many examples such as scketengine,animation... But i did not get it...As the examples are used in GUI app, but i use these timers in exe... plz help me... |
|






Forum posts: 20
Christian
Forum posts: 36
Can u help me in writing the code for setting expiry time for any app.
Forum posts: 1918
This has probably nothing to do with a timeout timer.
Such generic question cannot been answered through a forum. Think by yourself, take a look at other applications or hire a consultant to help you.
Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant