当前位置: 代码迷 >> 综合 >> TCallBack
  详细解决方案

TCallBack

热度:5   发布时间:2024-01-13 03:16:00.0

简单使用1:

  // timer to assist with displaying wait dialog
     CPeriodic* iWaitTimer;

 

  // create the timer used for callbacks
  iWaitTimer = CPeriodic::NewL( CActive::EPriorityHigh );

 

      if ( iWaitTimer->IsActive() )
        {
        PRINT( _L( "Camera <> timer already active" ) )
        iWaitTimer->Cancel();
        }
      PRINT( _L( "Camera <> start the exit timer" ) )
      iWaitTimer->Start( 0, 0,  TCallBack( CallExit, this ) ); 

 

 

简单使用2:

 

Can be used to pass an action to an active object request
? Takes a value: TAny * and function pointer: TInt (* aFunction )( TAny * aPtr )
? aFunction must be a non-member function or a static member function
? The TAny * value is passed to aFunction every time the CallBack () function of TCallBack object is called
If a member function needs to be called, this can be done like this:
? Use a static function of CObject
? Pass a CObject * aObject to TCallBack
? In the static function, call aObject -> MemberFunction ()
 

static TInt Function( TAny* param ); //belong to CObject

CObject* object = CObject::NewL();

TCallBack cb( Function, object );

cb.CallBack(); // results in call to Function( object );
  相关解决方案