声明
RThread iThread;
TBool StartThread(void);
static TInt ThreadRun(TAny *aPtr);
实现
StartThread(void)
{
TInt re = EFalse;
iThread.Close();
_LIT(ThreadName, "Thread");
TInt err = iThread.Create(ThreadName , ThreadRun, 10240, KMinHeapSize, 4096*KMinHeapSize, this , EOwnerProcess );
if(err == KErrNone)
{
iThread.Resume();
re = ETrue;
}
return re;
}
ThreadRun(TAny *aPtr)
{
CParenApp* myparent = static_cast<CParenApp*>(aPtr);
CTrapCleanup* cleanup = CTrapCleanup::New();
TRAPD(err,myparent->DoSomething());
if(err != KErrNone)
{
}
delete cleanup;
return KErrNone;
}
释放
//iThread.Kill(KErrNone);
iThread.Close();
1、线程中如果不使用清理栈可以不创建。
2、如果线程不是无限久,可以在最后加一个循环,这样可以调用iThread.Kill(KErrNone)结束。
3、线程当中能使用静态变量与法,其他可以通过传入指针间接使用。
Symbian 创建线程
最新推荐文章于 2016-09-01 19:50:28 发布