Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to renew a request from the active scheduler

It is possible to maintain an outstanding request from the active scheduler, by overriding the CActiveScheduler::WaitForAnyRequest() function.

In this case, it is useful for the active scheduler to have a data member which points to the active object for which it will maintain an outstanding request. Implement the active scheduler as follows:

class CExampleScheduler : public CActiveScheduler
    {
public:
    void Error (TInt aError) const;
    void WaitForAnyRequest();
    void SetActiveObject(CActiveConsole* aActiveConsole);
private:
    CActiveConsole* iActiveConsole;
    };

void CExampleScheduler::SetActiveObject(CActiveConsole* aActiveConsole)
    {
    iActiveConsole = aActiveConsole;
    }

where iActiveConsole is a pointer to an active object, initialised by call to SetActiveObject() during the construction of the controlling active object:

void CMessageKeyProcessor::ConstructL()
    {
    CActiveScheduler::Add(this);
    (CExampleScheduler*)(CActiveScheduler::Current())->SetActiveObject(this);
    }

Now override CActiveScheduler::WaitForAnyRequest():

void CExampleScheduler::WaitForAnyRequest()
    {
    if (!(iActiveConsole->IsActive()))
        {
        iActiveConsole->RequestCharacter();
        }
    CActiveScheduler::WaitForAnyRequest();
    }


Notes