idlefw/tsrc/mcsplugin/ut_mcssettings/caouserafter.h
branchRCL_3
changeset 28 053c6c7c14f3
equal deleted inserted replaced
27:2c7f27287390 28:053c6c7c14f3
       
     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 
       
    18 
       
    19 #ifndef __CAOUSERAFTER_H__
       
    20 #define __CAOUSERAFTER_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <E32base.h>
       
    24 #include <E32svr.h>
       
    25 #include <CoeMain.h>
       
    26 
       
    27 
       
    28 /**
       
    29  * Active object version of User::After()
       
    30  */
       
    31 class CAOUserAfter : public CTimer
       
    32     {
       
    33     private:
       
    34         CActiveSchedulerWait iWait;
       
    35         TInt                 iLength;
       
    36 
       
    37 
       
    38     public: //new functions
       
    39 
       
    40         /**
       
    41          * Constructs the waiting timer, executes
       
    42          * it and when timer expires, deletes self.
       
    43          * @param aLength The lenghth of wait in micro
       
    44          *        seconds.
       
    45          */
       
    46         static void AfterLD( TInt aLenght )
       
    47             {
       
    48             CAOUserAfter* wait= new ( ELeave ) CAOUserAfter( aLenght );
       
    49             CleanupStack::PushL( wait );
       
    50             wait->ConstructL();
       
    51             CleanupStack::Pop();
       
    52 
       
    53             RDebug::Print( _L("CAOUserAfter - Starting time consuming...") );
       
    54             wait->StartWaitD();
       
    55             RDebug::Print( _L("CAOUserAfter - completed.") );
       
    56             }
       
    57 
       
    58     private:
       
    59         CAOUserAfter( TInt aLenght )
       
    60            : CTimer( CActive::EPriorityStandard ),
       
    61              iLength( aLenght )
       
    62             {
       
    63             }
       
    64 
       
    65         void ConstructL()
       
    66             {
       
    67             CTimer::ConstructL();
       
    68             CActiveScheduler::Add( this );
       
    69             }
       
    70 
       
    71        virtual ~CAOUserAfter()
       
    72             {
       
    73             }
       
    74 
       
    75         void StartWaitD()
       
    76             {
       
    77             After( iLength );
       
    78             iWait.Start();
       
    79             }
       
    80 
       
    81         void RunL()
       
    82             {
       
    83             iWait.AsyncStop();
       
    84             Cancel();
       
    85             delete this;
       
    86             }
       
    87     };
       
    88 
       
    89 #endif // __CAOUSERAFTER_H__
       
    90 
       
    91 // End of File