Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



How to start active objects

The following example code shows how active objects are started. While the example shows the creation of an active scheduler, in UI applications, an active scheduler is always provided.

LOCAL_C void doExampleL()
    {
        // Create and install the active scheduler
    CActiveScheduler* exampleScheduler=new (ELeave) CActiveScheduler;
    CleanupStack::PushL(exampleScheduler);
    CActiveScheduler::Install(exampleScheduler);

        // Create the service provider. Often, the
        // service provider is part of the active object
    CExampleServiceProvider* myServiceProvider=new (ELeave) CExampleServiceProvider;
    CleanupStack::PushL(myServiceProvider);

        // Create the active object and issue the
        // first asynchronous request
    CExampleActiveObject * myActiveObject=new (ELeave) CExampleActiveObject(myServiceProvider);
    CleanupStack::PushL(myActiveObject);
    myActiveObject->IssueRequest();

        // Now we can start the active scheduler
    CActiveScheduler::Start();

        // Remove the exampleScheduler and other
        // objects from cleanup stack and destroy them
    CleanupStack::PopAndDestroy(3);
    }