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