×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Apr 2004
    Posts
    322

    start a thread from another thread

    Hi
    I want to start another thread from within a CActive class.
    I understand that a good way is to create another CActive derived class and start it.
    I added the relevant init code of my main CActive derived class.
    also there is non working code I tried in the RunL method ...
    What is the way to start a new thread from the main CActive class ?
    does the second CActive class have the same init methods ?
    Do I have to create a new scheduler ?
    Do I use SetActive() in the second thread ?
    Please advise about this issue

    Thanks in advance

    Code:
    void CMyAppUi::ConstructL()
    {
    	iActiveClass=CActiveClass::NewL(this);
    }
    
    CActiveClass* CActiveClass::NewL(CMyAppUi * aAppUi)
    {
    	CActiveClass* self = new (ELeave) CActiveClass();
    	self->iAppUi = aAppUi;
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	CleanupStack::Pop(self);
    	return self;
    }
    
    CActiveClass::CActiveClass()
    : CActive(CActive::EPriorityStandard)
    {
    	CActiveScheduler::Add(this);
    }
    
    void CActiveClass::ConstructL()
    {
    	SetActive(); 
    }
    	
    void CActiveClass::RunL()
    {
    	//*** here I want to start another Active Class ***
    
    	/* I tried this code but it didnt work :
    	iSecondActiveClass=CSecondActiveClass::NewL(iAppUi);
    	CActiveScheduler* current = CActiveScheduler::Current();
    	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
    	CActiveScheduler::Install(NULL); 
    	CActiveScheduler::Install(scheduler); 
    	CActiveScheduler::Add(iSecondActiveClass);
    	CActiveScheduler::Start();
    	CActiveScheduler::Replace(current);*/
    }

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167
    maybe you should read the "threads programming" paper written by Nokia, it gives quite good pointers on using threads.

    yucca

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×