Using CTimer????

Login to reply to this topic.
Tue, 2003-10-21 07:56
Joined: 2003-10-17
Forum posts: 16
Hi,

I'm deriving from CTimer class, to create a timer to display a splash screen.  My timer is instantiated in ConstructL of the AppUi class, I pass it a pointer to my Container class (which does the drawing).  The idea behind this is that when the timer expires it will call the RunL method which in my case is used to set a flag in the container class to stop it from drawing the splash screen code, & to set the controls for the main view visible.

However, when I try & call the SetActive() method on the timer (before I call After()) SetActive crashes.  If I call After() before I call SetActive, After() crashes.

Have I forgotten something?  Am I doing something wrong?  Any help would be muchly appreciated as I have been stuck on this for a long time.

Thanks.

Tue, 2003-10-21 08:06
Anonymous (not verified)
Forum posts: 2043
Using CTimer????
Hope this helps .... (uses CPeriodic but I guess CTimer would work just fine ...)  Please post back here if it does work!

Code:
// Start the timer (this is set to 100ms)
void MyClass::start() {
if(timer==0) {
timer=CPeriodic::New(CActive::EPriorityStandard);
timer->Start(TTimeIntervalMicroSeconds32(100000),TTimeIntervalMicroSeconds32(100000),TCallBack(TimeTick,this));
}
}

// Method in MyClass which will get called by the TimeTick function when the timer goes off
void MyClass::tick() {
               // Do whatever
}

// Global function which simply passes the timer tick back to MyClass
TInt TimeTick(TAny *obj) {
((MyClass *)obj)->tick();
return 0;
}
Tue, 2003-10-21 08:07
Joined: 2003-09-11
Forum posts: 29
Using CTimer????
Has anyone else noticed that the forum often posts you as guest rather than the user you are logged in as?
Tue, 2003-10-21 08:13
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2009
Using CTimer????
Yes, it happens. But I did not yet understand when this happens.
I used to have the problem some weeks ago but I cannot reproduce it.
And I have not found any solution in phpbb to solve this.

Sorry for the inconvenience.
Eric

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Tue, 2003-12-16 15:29
Joined: 2003-10-17
Forum posts: 4
Re: Using CTimer????
-Call your draw  here (to show a splash image)
-Call StartTimer()


// After Splash bilden
void CAAppUi::StartTimer()
   {
   if(iPeriodic) StopTimer();
// How long the splash will be viewd
   const TInt tickInterval=3000000;
   iPeriodic=CPeriodic::NewL(0);
   iPeriodic->Start(tickInterval,tickInterval,TCallBack(Tick, this));
   }
void CAAppUi::StopTimer()
   {
   if(iPeriodic)
      {
       iPeriodic->Cancel();
       delete iPeriodic;
       iPeriodic = NULL;
       }
   }

// This method must be protected in your header file
TInt CAAppUi::Tick(TAny* aObject)
   {
   return ((CAAppUi*)aObject)->DoTick();
   }
TInt CAAppUi::DoTick()
   {
   // Go on and start the rest of your program
   return 0;
   }

/Fadi
  • Login to reply to this topic.