Hi All,
I'm trying to implement a bacgkroud processing using RThread. In one of my clases.
I call the createthread method with the name of the threadfuntion which is a static method, which takes tAny*. And am also passing the "this" pointer to the createthread object.
And then call thread.resume()
Now when I rup the app, I can see that the thread is being created, but it does not call the thread function.
Here is my code: please let me know what is the issue with it
//////////////////////////////////////////////////////////////
//// start a diff thread
iThread = new(ELeave)RThread();
TInt res = iThread->Create(_L("CNet Thread"), ThreadEntryPoint,KDefaultStackSize, this, NULL, NULL, KMinHeapSize, KMinHeapSize, EOwnerProcess );
#ifdef _DEBUG
iLog.WriteFormat(_L("After creating the thread:[%d]"), res);
#endif
if (KErrNone!=res)
{// Complete the caller immediately
//User::RequestComplete(iCaller, res);
}
else
{// Set active; resume new thread to make the synchronous call
// (Change the priority of the thread here if required)
// Set the caller and ourselves to KRequestPending
// so the active scheduler notifies on completion
#ifdef _DEBUG
iLog.Write(_L("Starting the thread "));
#endif
//*iCaller = KRequestPending;
//iStatus = KRequestPending;
//SetActive();
#ifdef _DEBUG
iLog.Write(_L("After calling setactive"));
#endif
//iThread->Logon(iStatus); // Request notification when thread dies
iThread->Resume(); // Start the thread
#ifdef _DEBUG
iLog.Write(_L("After Starting the thread"));
#endif
}
////////////////////////////////////////////////////////////
//// end of thread
TInt CCNetPlugin::ThreadEntryPoint(TAny* aParameters)
{
// Perform a long synchronous task e.g. a lengthy calculation
CCNetPlugin* pThis = (CCNetPlugin*)aParameters;
#ifdef _DEBUG
pThis->iLog.Write(_L("Thread entry point"));
if(pThis)
{
pThis->iLog.Write(_L("Pthis is not NULL"));
}
else
{
pThis->iLog.Write(_L("Pthis is NULL"));
}
#endif
return(KErrNone);
}

Reply With Quote

