diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-9C36CF76-6ED2-5674-908F-A3DF8930CEB0.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-9C36CF76-6ED2-5674-908F-A3DF8930CEB0.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,65 @@ + + + + + +How +to renew a request from the active schedulerThis document describes how to maintain an outstanding request +from an 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, +initialized 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
    +
  • 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.

  • +
  • It is no longer necessary +to call RequestCharacter() either before starting the active +scheduler, or as part of key processing.

  • +
  • The static function CActiveScheduler::Current() is +used to fetch a pointer to the currently installed active scheduler (in this +example, an object of type CExampleScheduler). This is necessary +in order to access the SetActiveObject() member function +of CExampleScheduler.

  • +
+
\ No newline at end of file