00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "CommonFramework.h"
00018 #include <e32math.h>
00019
00020
00021
00022
00023
00024
00025 _LIT(KMsgMyThreadName, "MyThread");
00026 _LIT(KMsgStartThread, "Start thread\n");
00027 _LIT(KMsgThreadRendezvousReached,"Thread rendezvous reached\n");
00028 _LIT(KMsgEndOfTest,"End of test\n");
00029 _LIT(KMsgSomethingIsWrong, "Something is wrong\n");
00030 _LIT(KMsgCreateThreadFailed, "Create thread failed\n");
00031
00032
00033 const TInt KHeapSize = 0x2000;
00034
00035
00036
00037
00038 TInt MyThread(TAny* aParameter)
00039 {
00040
00041 User::After((TInt)aParameter);
00042
00043
00044 RThread::Rendezvous(KErrNone);
00045
00046
00047 User::After((TInt)aParameter);
00048
00049 return(KErrNone);
00050 }
00051
00052
00053
00054
00055 LOCAL_C void doExampleL()
00056 {
00057
00058 RThread thread;
00059
00060
00061 TRequestStatus myThreadRendezvousStatus;
00062
00063
00064 TInt r=thread.Create(KMsgMyThreadName, MyThread, KDefaultStackSize, KHeapSize,KHeapSize,(TAny*) 2000000, EOwnerThread);
00065 if (r!=KErrNone)
00066 {
00067 console->Printf(KMsgCreateThreadFailed);
00068 return;
00069 }
00070
00071 thread.Rendezvous(myThreadRendezvousStatus);
00072
00073
00074 console->Printf(KMsgStartThread);
00075 thread.Resume();
00076
00077 User::WaitForRequest(myThreadRendezvousStatus);
00078 if(myThreadRendezvousStatus==KErrNone)
00079 {
00080 console->Printf(KMsgThreadRendezvousReached);
00081 }
00082 else
00083 {
00084 console->Printf(KMsgSomethingIsWrong);
00085 }
00086
00087 thread.Close();
00088 console->Printf(KMsgEndOfTest);
00089
00090 }
00091
00092
00093
00094
00095
00096
00097
00098