idlefw/tsrc/idleint/ut_idleint/CAOUserAfter.h
branchRCL_3
changeset 27 2c7f27287390
equal deleted inserted replaced
25:9e077f9a342c 27:2c7f27287390
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #ifndef __CAOUSERAFTER_H__
       
    18 #define __CAOUSERAFTER_H__
       
    19 
       
    20 // INCLUDES
       
    21 #include <E32base.h>
       
    22 #include <E32svr.h>
       
    23 #include <CoeMain.h>
       
    24 
       
    25 
       
    26 /**
       
    27  * Active object version of User::After()
       
    28  */
       
    29 class CAOUserAfter : public CTimer
       
    30     {
       
    31     private:
       
    32         CActiveSchedulerWait iWait;
       
    33         TInt                 iLength;
       
    34 
       
    35 
       
    36     public: //new functions
       
    37 
       
    38         /**
       
    39          * Constructs the waiting timer, executes
       
    40          * it and when timer expires, deletes self.
       
    41          * @param aLength The lenghth of wait in micro
       
    42          *        seconds.
       
    43          */
       
    44         static void AfterLD( TInt aLenght )
       
    45             {
       
    46             CAOUserAfter* wait= new ( ELeave ) CAOUserAfter( aLenght );
       
    47             CleanupStack::PushL( wait );
       
    48             wait->ConstructL();
       
    49             CleanupStack::Pop();
       
    50 
       
    51             RDebug::Print( _L("CAOUserAfter - Starting time consuming...") );
       
    52             wait->StartWaitD();
       
    53             RDebug::Print( _L("CAOUserAfter - completed.") );
       
    54             }
       
    55 
       
    56     private:
       
    57         CAOUserAfter( TInt aLenght )
       
    58            : CTimer( CActive::EPriorityStandard ),
       
    59              iLength( aLenght )
       
    60             {
       
    61             }
       
    62 
       
    63         void ConstructL()
       
    64             {
       
    65             CTimer::ConstructL();
       
    66             CActiveScheduler::Add( this );
       
    67             }
       
    68 
       
    69        virtual ~CAOUserAfter()
       
    70             {
       
    71             }
       
    72 
       
    73         void StartWaitD()
       
    74             {
       
    75             After( iLength );
       
    76             iWait.Start();
       
    77             }
       
    78 
       
    79         void RunL()
       
    80             {
       
    81             iWait.AsyncStop();
       
    82             Cancel();
       
    83             delete this;
       
    84             }
       
    85     };
       
    86 
       
    87 #endif // __CAOUSERAFTER_H__
       
    88 // End of File
       
    89