大家好,我create一个线程,有问题,我新手,还请大家帮的看看问题在哪里,谢谢了!
代码:
TInt res=iThread.Create(KThreadName,DoAsyncTask,KDefaultStackSize,
NULL,KMinHeapSize,KMinHeapSize,EOwnerProcess);
错误:
error: function call '[RThread].Create({lval} const TLitC<10>, int (CCamEngine::*)(), {lval} const int, int, {lval} const int, {lval} const int, TOwnerType)' does not match
说我函数的参数不对。可是我是按照一个函数的重载形式写的啊。里面的参数我都用“go to definition”试过,都有定义的。我没什么经验,还请大家给看看。
谢谢了!
------解决方案--------------------------------------------------------
参考一下我的
ReceProcessThread = new CReceProcess();
TInt t1=iReceThread.Create(KName, TestRecethread, 0x3000, 0x3000, 0x300000,this, EOwnerProcess);
if(t1!=KErrNone)
{
return ;//Create failed;
}
else {
iReceThread.Resume();
}
------解决方案--------------------------------------------------------
我贴多了,简单完整的, 你应该能得到答案:)
void CEngine::ConstructL()
{
_LIT(KName1,"thread1");
TThreadFunction fun1=ThreadFun1;
iThread1.Create(KName1, fun1, 0x10000, 0x10000, 0x20000, this, EOwnerProcess);
_LIT(KName2,"thread2");
TThreadFunction fun2=ThreadFun2;
iThread2.Create(KName2, fun2, 0x10000, 0x10000, 0x20000, this, EOwnerProcess);
}
TInt CEngine::ThreadFun1(TAny* aData)
{
CEngine* self=(CEngine*) aData;
TInt& a=self->iValue;
while (ETrue)
{
if (a > 100)
{
a = 0;
}
User::After(0.1*1000*1000);
if (self->iObser)
{
self->iObser->Compelete(a);
}
User::After(0.1*1000*1000);
++a;
}
return 0;
}
TInt CEngine::ThreadFun2(TAny* aData)
{
TInt b=0;
while (ETrue)
{
b++;
}
return 0;
}
------解决方案--------------------------------------------------------
KName当然不能用简单的字符串,又不是char[].
简单解决方法:
TBuf<16> KName;
KName.AppendNum(random一个数);