Symbian3/PDK/Source/GUID-9C36CF76-6ED2-5674-908F-A3DF8930CEB0.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 11 Mar 2010 18:02:22 +0000
changeset 3 46218c8b8afa
parent 1 25a17d01db0c
child 5 f345bda72bc4
permissions -rw-r--r--
week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-9C36CF76-6ED2-5674-908F-A3DF8930CEB0" xml:lang="en"><title>How
to renew a request from the active scheduler</title><shortdesc>This document describes how to maintain an outstanding request
from an active scheduler.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>It is possible to maintain an outstanding request from the active scheduler,
by overriding the <codeph>CActiveScheduler::WaitForAnyRequest()</codeph> function.</p>
<p>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:</p>
<codeblock id="GUID-92FD6B7D-54E8-5E1D-828F-AEE77C45CA3A" xml:space="preserve">class CExampleScheduler : public CActiveScheduler
    {
public:
    void Error (TInt aError) const;
    void WaitForAnyRequest();
    void SetActiveObject(CActiveConsole* aActiveConsole);
private:
    CActiveConsole* iActiveConsole;
    };</codeblock>
<codeblock id="GUID-156BDAD4-B9EB-55AB-827A-16739A66AC2D" xml:space="preserve">void CExampleScheduler::SetActiveObject(CActiveConsole* aActiveConsole)
    {
    iActiveConsole = aActiveConsole;
    }</codeblock>
<p>where <codeph>iActiveConsole</codeph> is a pointer to an active object,
initialized by call to <codeph>SetActiveObject()</codeph> during the construction
of the controlling active object:</p>
<codeblock id="GUID-721C2A53-CE4F-5C37-9599-DE359A586C9C" xml:space="preserve">void CMessageKeyProcessor::ConstructL()
    {
    CActiveScheduler::Add(this);
    (CExampleScheduler*)(CActiveScheduler::Current())-&gt;SetActiveObject(this);
    }</codeblock>
<p>Now override <codeph>CActiveScheduler::WaitForAnyRequest()</codeph>:</p>
<codeblock id="GUID-7646ED79-B891-5F94-BCBC-37A025FA5270" xml:space="preserve">void CExampleScheduler::WaitForAnyRequest()
    {
    if (!(iActiveConsole-&gt;IsActive()))
        {
        iActiveConsole-&gt;RequestCharacter();
        }
    CActiveScheduler::WaitForAnyRequest();
    }</codeblock>
<section id="GUID-52635F6A-E5F8-4F08-A77F-136FC80C39BF"><title>Notes</title> <ul>
<li id="GUID-76CC4644-1909-5423-BF85-44F6AA4053A3"><p>The state of the active
request flag is examined and a request is not issued if it is active. This
check is important because the function may be called as a result of other
active objects completing (for example, a timed messenger) and in these cases
it would be inappropriate to renew the keyboard service request.</p> </li>
<li id="GUID-5DA7C2E5-4BB2-54B1-9800-53FB2E41793D"><p>It is no longer necessary
to call <codeph>RequestCharacter()</codeph> either before starting the active
scheduler, or as part of key processing.</p> </li>
<li id="GUID-7535854A-24C9-581C-9B49-FE17E2252E8E"><p>The static function <codeph>CActiveScheduler::Current()</codeph> is
used to fetch a pointer to the currently installed active scheduler (in this
example, an object of type <codeph>CExampleScheduler</codeph>). This is necessary
in order to access the <codeph>SetActiveObject()</codeph> member function
of <codeph>CExampleScheduler</codeph>.</p> </li>
</ul> </section>
</conbody></concept>