00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // Shows asynchronous programming (without active objects). 00015 // Example shows how a single request can be issued, followed 00016 // by User::WaitForRequest() 00017 // 00018 00019 00020 #include "CommonFramework.h" 00021 00022 00023 00024 // Do the example 00025 LOCAL_C void doExampleL() 00026 { 00027 // create and initialize heartbeat timer 00028 RTimer heartbeat; // heartbeat timer 00029 00030 TRequestStatus heartbeatStatus; // request status associated with it 00031 heartbeat.CreateLocal(); // always created for this thread 00032 00033 // go round timing loop 00034 for (TInt i=0; i<10; i++) 00035 { 00036 // issue and wait for single request 00037 heartbeat.After(heartbeatStatus,1000000); // wait 1 second 00038 User::WaitForRequest(heartbeatStatus); // wait for request 00039 // to complete 00040 // say we're here 00041 _LIT(KFormatString1,"Tick %d\n"); 00042 console->Printf(KFormatString1, i); 00043 } 00044 00045 // close timer 00046 heartbeat.Close(); // close timer 00047 }