diff -r 4816d766a08a -r f345bda72bc4 Symbian3/PDK/Source/GUID-E5B5C3CA-B256-5B29-AB90-590676444C85.dita --- a/Symbian3/PDK/Source/GUID-E5B5C3CA-B256-5B29-AB90-590676444C85.dita Tue Mar 30 11:42:04 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-E5B5C3CA-B256-5B29-AB90-590676444C85.dita Tue Mar 30 11:56:28 2010 +0100 @@ -1,42 +1,42 @@ - - - - - -How -to start a periodic timerProvides code snippets to show you how to start a periodic timer -

A periodic timer, CPeriodic, invokes a function at regular -intervals. You must wrap the function to be called in a TCallBack.

-

First, we provide a callback function for the timer to call. The callback -function can be a static member, i.e. TInt X::Foo(TAny *) or -global, i.e. TInt Foo(TAny *). The TAny* can -point to any object that we specify when we start the timer.

-

It is awkward to deal with TAny*, and more convenient -to write handler code from a non-static member function, so here we code a -static function to invoke a non-static function DoTick() as -follows:

-TInt CPeriodicRunner::Tick(TAny* aObject) - { - // cast, and call non-static function - ((CPeriodicRunner*)aObject)->DoTick(); - return 1; - } - -

The next piece of code creates a CPeriodic and sets it -off with one-second ticks. The callback is specified to call the static Tick() function, -passing the this pointer (which we use in Tick() to -call DoTick()).

-void CPeriodicRunner::StartTimer() - { - const TInt tickInterval=1000000; - iPeriodic=CPeriodic::NewL(0); // neutral priority - iPeriodic->StartInMicroSeconds(tickInterval,tickInterval,TCallBack(Tick, this)); - } - + + + + + +How +to start a periodic timerProvides code snippets to show you how to start a periodic timer +

A periodic timer, CPeriodic, invokes a function at regular +intervals. You must wrap the function to be called in a TCallBack.

+

First, we provide a callback function for the timer to call. The callback +function can be a static member, i.e. TInt X::Foo(TAny *) or +global, i.e. TInt Foo(TAny *). The TAny* can +point to any object that we specify when we start the timer.

+

It is awkward to deal with TAny*, and more convenient +to write handler code from a non-static member function, so here we code a +static function to invoke a non-static function DoTick() as +follows:

+TInt CPeriodicRunner::Tick(TAny* aObject) + { + // cast, and call non-static function + ((CPeriodicRunner*)aObject)->DoTick(); + return 1; + } + +

The next piece of code creates a CPeriodic and sets it +off with one-second ticks. The callback is specified to call the static Tick() function, +passing the this pointer (which we use in Tick() to +call DoTick()).

+void CPeriodicRunner::StartTimer() + { + const TInt tickInterval=1000000; + iPeriodic=CPeriodic::NewL(0); // neutral priority + iPeriodic->StartInMicroSeconds(tickInterval,tickInterval,TCallBack(Tick, this)); + } +
\ No newline at end of file