00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "CommonFramework.h"
00018
00019
00020 void showTimeL(TTime aTime)
00021 {
00022
00023
00024
00025
00026 TBuf<40> timeString;
00027 _LIT(KFormat1,"%:0%H%:1%T%:2%S%:3");
00028 aTime.FormatL(timeString,KFormat1);
00029 _LIT(KFormat2,"(24 hr clock) = %S\n");
00030 console->Printf(KFormat2, &timeString);
00031 }
00032
00033
00034 void WaitForKey()
00035 {
00036 _LIT(KTxtPressAnyKey,"Press any key to continue\n\n");
00037 console->Printf(KTxtPressAnyKey);
00038 console->Getch();
00039 }
00040
00041
00042 LOCAL_C void doExampleL()
00043 {
00044 RTimer timer;
00045 TRequestStatus timerStatus;
00046 timer.CreateLocal();
00047
00048
00049 _LIT(KTxt1,"Doing 10 after requests\n");
00050 console->Printf(KTxt1);
00051 for (TInt i=0; i<10; i++)
00052 {
00053
00054 timer.After(timerStatus,1000000);
00055 User::WaitForRequest(timerStatus);
00056
00057 _LIT(KFormat3,"Request count %d\n");
00058 console->Printf(KFormat3, i);
00059 }
00060
00061 WaitForKey();
00062
00063
00064 TTime time;
00065 _LIT(KTxt2,"The time now is, ");
00066 console->Printf(KTxt2);
00067
00068
00069 time.HomeTime();
00070 showTimeL(time);
00071
00072
00073 TTimeIntervalSeconds timeIntervalSeconds(10);
00074 time += timeIntervalSeconds;
00075 _LIT(KTxt3,"Doing a request ten seconds from now at, ");
00076 console->Printf(KTxt3);
00077 showTimeL(time);
00078
00079
00080
00081 timer.At(timerStatus,time);
00082
00083
00084 User::WaitForRequest(timerStatus);
00085
00086
00087 _LIT(KTxt4,"Your 10 seconds are up\nThe time now is, ");
00088 console->Printf(KTxt4);
00089
00090
00091 time.HomeTime();
00092
00093
00094 showTimeL(time);
00095
00096
00097 timer.Close();
00098 }
00099