Symbian3/SDK/Source/GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?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-E63545EC-172E-53F3-B0B3-EA5150FD92D8" xml:lang="en"><title>Asynchronous
Services Example Codes</title><shortdesc>Explains how to use asynchronous requests.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<ul>
<li id="GUID-3CEEC547-CB45-5BC4-85BE-C2DF97663BE9"><p><xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-9D95DEED-4E6A-5139-9188-DD7FA0A4B906">SingleRequest: asynchronous programming without active objects</xref>  </p> </li>
<li id="GUID-0A475759-3571-5F7A-986C-45F93257C2CE"><p><xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-D9B89770-81F8-52ED-848E-F79A92858C37">WaitLoop: asynchronous programming without active objects</xref>  </p> </li>
<li id="GUID-442DA981-732E-5F21-8140-A7E998099B25"><p><xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-F6C2B633-E744-5B40-819D-6615406A9664">RealLifeWaitLoop: asynchronous programming without active objects</xref>  </p> </li>
<li id="GUID-0CC6DC14-4CE8-500E-A9BE-BF147E5BC130"><p><xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-D3EA20C0-AF5C-5AFE-8014-48CB92851463">RunComplete: asynchronous programming with active objects</xref>  </p> </li>
<li id="GUID-5B75E3E3-4AD4-51FD-828D-0A81BF0AE087"><p><xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-802DB10F-150B-5A76-BFC8-A7E8EB4A68D6">AcceptInput1-2: asynchronous programming with active objects</xref>  </p> </li>
<li id="GUID-2E15F495-27E3-57F6-BB79-E392237F7E8D"><p><xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-1BEA3D45-21A2-54AB-ABBD-EF23716FE6B5">AcceptPrintInput: asynchronous programming with active objects</xref>  </p> </li>
<li id="GUID-A16AA99F-366E-5EED-85CF-7372F177EBFF"><p><xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-AD4D25CA-B0BF-54BD-8029-DD495AB56C5E">Fibonacci1-3: asynchronous programming with active objects</xref>. </p> </li>
</ul>
<section id="GUID-9D95DEED-4E6A-5139-9188-DD7FA0A4B906"><title>SingleRequest:
asynchronous programming without active objects</title> <p><b>Download</b> </p> <p>Click
on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-5649e475-b630-4411-ae06-99a03f575dbd.zip" scope="external"> SingleRequest.zip </xref></p><p>Click on the following link
to download additional file: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.zip" scope="external"> CommonFramework.zip </xref></p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-5649e475-b630-4411-ae06-99a03f575dbd.html" scope="peer"> browse SingleRequest </xref> to view the example code.</p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.html" scope="peer"> browse CommonFramework </xref> to view the additional file.</p> <p>Click
on the below link for Example which demonstrates Asynchronous requests<xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-9f4be784-fb23-4a66-9f7f-d44b28fe98c1.zip" scope="external"> ClientServerAsync .zip</xref> .</p><p>Browse
the S60 files.<xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-9f4be784-fb23-4a66-9f7f-d44b28fe98c1.html" scope="external"> ClientServerAsync </xref> .</p><p><b>Description</b> </p> <p>This
example shows how to issue and wait for a single request. </p> <p>The example
shows the general principles involved in asynchronous programming. It uses
a simple wait loop and shows how the completion of asynchronous events are
handled <i>without</i> active objects. </p> <p>This example does not use active
objects <i>deliberately</i>. </p><p><b>Class summary</b></p><p><xref href="GUID-E0B34F3E-D4C4-3232-B8B1-7DB35B454646.dita"><apiname>TRequestStatus</apiname></xref></p> <p><b>Security
issues</b> </p> <p>The example requires no specific capabilities in order
to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-D9B89770-81F8-52ED-848E-F79A92858C37"><title>WaitLoop: asynchronous
programming without active objects</title> <p><b>Download</b> </p> <p>Click
on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-a1802d10-4226-43b8-a616-093ecb286eff.zip" scope="external"> Waitloop.zip </xref></p><p>Click on the following link to
download additional file: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.zip" scope="external"> CommonFramework.zip </xref></p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-a1802d10-4226-43b8-a616-093ecb286eff.html" scope="peer"> browse Waitloop </xref> to view the example code.</p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.html" scope="peer"> browse CommonFramework </xref> to view the additional file.</p> <p><b>Description</b> </p> <p>This
example shows how a wait loop can be used to identify and handle a completed
request. </p> <p>It shows the general principles involved in asynchronous
programming. It uses a simple wait loop and shows how the completion of asynchronous
events are handled <i>without</i> active objects. </p> <p>This example does
not use active objects <i>deliberately</i>. </p><p><b>Class summary</b></p><p><xref href="GUID-E0B34F3E-D4C4-3232-B8B1-7DB35B454646.dita"><apiname>TRequestStatus</apiname></xref></p> <p><b>Security
issues</b> </p> <p>The example requires no specific capabilities in order
to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-F6C2B633-E744-5B40-819D-6615406A9664"><title>RealLifeWaitLoop:
asynchronous programming without active objects</title> <p><b>Download</b> </p> <p>Click
on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4d03bc9b-a832-427b-9e78-b593d3618267.zip" scope="external"> RealLifeWaitLoop.zip </xref></p><p>Click on the following
link to download additional files:<xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.zip" scope="external"> CommonFramework.zip </xref></p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4d03bc9b-a832-427b-9e78-b593d3618267.html" scope="peer"> browse RealLifeWaitLoop </xref> to view example code.</p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.html" scope="peer"> browse CommonFramework </xref> to view the additional file.</p> <p><b>Description</b> </p> <p>As
with the <xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-D9B89770-81F8-52ED-848E-F79A92858C37">WaitLoop</xref> example,
this example shows how a wait loop can be used to identify and handle a completed
request. However, this example shows how the wait loop can deal with multiple
asynchronous service providers. </p> <p>The example shows the general principles
involved in asynchronous programming; it uses a simple wait loop and shows
how the completion of asynchronous events are handled <i>without</i> active
objects. </p> <p>This example <i>deliberately</i> does not use active objects. </p><p><b>Class
summary</b></p><p><xref href="GUID-E0B34F3E-D4C4-3232-B8B1-7DB35B454646.dita"><apiname>TRequestStatus</apiname></xref></p> <p><b>Security issues</b> </p> <p>The
example requires no specific capabilities in order to run - and does not demonstrate
any security issues. </p> </section>
<section id="GUID-D3EA20C0-AF5C-5AFE-8014-48CB92851463"><title>RunComplete:
asynchronous programming with active objects</title> <p><b>Download</b> </p> <p>Click
on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-0820a8bc-295c-45fb-875b-33eb81b907b8.zip" scope="external"> RunComplete.zip </xref></p><p>Click on the following link
to download additional files:<xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.zip" scope="external"> CommonFramework.zip </xref></p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-0820a8bc-295c-45fb-875b-33eb81b907b8.html" scope="peer"> browse RunComplete </xref> to view the example code.</p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.html" scope="peer"> browse CommonFramework </xref> to view the additional file.</p> <p><b>Description</b> </p> <p>The
example shows how active objects and an active scheduler can be used to handle
asynchronous events. Compare this with the following examples; <xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-9D95DEED-4E6A-5139-9188-DD7FA0A4B906">SingleRequest</xref>, <xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-D9B89770-81F8-52ED-848E-F79A92858C37">WaitLoop</xref> and <xref href="GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8.dita#GUID-E63545EC-172E-53F3-B0B3-EA5150FD92D8/GUID-F6C2B633-E744-5B40-819D-6615406A9664">RealLifeWaitLoop</xref>. </p> <p>It
demonstrates a single <codeph>CMessageTimer</codeph> active object which runs
until completion. </p><p><b>Class summary</b></p><p> <xref href="GUID-E0B34F3E-D4C4-3232-B8B1-7DB35B454646.dita"><apiname>TRequestStatus </apiname></xref>  <xref href="GUID-B4C76104-EA1B-3FC3-A31E-86A976598171.dita"><apiname>CActiveScheduler </apiname></xref>  <xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname>CActive </apiname></xref> <xref href="GUID-5733DF34-5B54-3044-BBED-3BFECB7ACE7A.dita"><apiname> CTimer</apiname></xref>  </p> <p><b>Security issues</b> </p> <p>The example
requires no specific capabilities in order to run - and does not demonstrate
any security issues. </p> </section>
<section id="GUID-802DB10F-150B-5A76-BFC8-A7E8EB4A68D6"><title>AcceptInput1-2:
asynchronous programming with active objects</title> <p><b>Download</b> </p> <p>Click
on the following links to download the examples:</p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-16b394b8-da07-4325-aaab-2af5d07b881f.zip" scope="external"> AcceptInput1.zip</xref> </p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-7fbe04f9-1bf5-4957-a2f4-94992d0d2cc4.zip" scope="external"> AcceptInput2.zip</xref></p><p>Click on the following link
to download additional files:<xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.zip" scope="external"> CommonFramework.zip </xref></p><p>Click on the following
links to view the examples:</p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-16b394b8-da07-4325-aaab-2af5d07b881f.html" scope="peer"> browse AcceptInput1 </xref></p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-7fbe04f9-1bf5-4957-a2f4-94992d0d2cc4.html" scope="peer">browse AcceptInput2 </xref></p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.html" scope="peer"> browse CommonFramework </xref> to view the additional file.</p> <p><b>Description</b> </p> <p>These
examples show how active objects and an active scheduler can be used to handle
asynchronous events. </p> <p>They demonstrate a single <codeph>CKeyMessengerProcessor</codeph> active
object (derived from class <codeph>CActiveConsole</codeph>), which accepts
input from keyboard, but does not print it. This object contains a <codeph>CMessageTimer</codeph> object
which it activates if the user inputs the character "m" and cancelled if the
user inputs "c". </p><p><b>Class summary</b></p><p><xref href="GUID-E0B34F3E-D4C4-3232-B8B1-7DB35B454646.dita"><apiname>TRequestStatus </apiname></xref>  <xref href="GUID-B4C76104-EA1B-3FC3-A31E-86A976598171.dita"><apiname>CActiveScheduler </apiname></xref> <xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname>CActive </apiname></xref> <xref href="GUID-5733DF34-5B54-3044-BBED-3BFECB7ACE7A.dita"><apiname> CTimer</apiname></xref>  </p> <p><b>Security issues</b> </p> <p>The example
requires no specific capabilities in order to run - and does not demonstrate
any security issues. </p> </section>
<section id="GUID-1BEA3D45-21A2-54AB-ABBD-EF23716FE6B5"><title>AcceptPrintInput:
asynchronous programming with active objects</title> <p><b>Download</b> </p> <p>Click
on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-285678f7-e35c-45ae-8074-8246fb6b1e90.zip" scope="external">AcceptPrintInput.zip</xref></p><p>Click on the following
link to download additional files: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.zip" scope="external">CommonFramework.zip</xref></p><p>View the source code<xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-285678f7-e35c-45ae-8074-8246fb6b1e90.html" scope="peer"> browse AcceptPrintInput</xref>. View the additional file: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-4184e6d4-8dbe-4267-b1a3-8737c8bf64ce.html" scope="peer">browse CommonFramework</xref>.</p> <p><b>Description</b> </p> <p>This
example demonstrates how to accept and print keyboard input to a console using
active objects. </p> <p>The example implements a class called <codeph>CWriteKeyProcessor</codeph> which
is an active object that requests and handles keyboard input in its <codeph>ProcessKeyPress()</codeph> method.
An alphabetic or space character is printed as a character, anything else
is printed as an integer. Pressing the escape key terminates the application. </p><p><b>Class
summary</b></p><p> <xref href="GUID-B4C76104-EA1B-3FC3-A31E-86A976598171.dita"><apiname>CActiveScheduler </apiname></xref><xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname>CActive </apiname></xref> <xref href="GUID-5733DF34-5B54-3044-BBED-3BFECB7ACE7A.dita"><apiname>CTimer</apiname></xref>  </p> <p><b>Security
issues</b> </p> <p>The example requires no specific capabilities in order
to run - and does not demonstrate any security issues. </p> </section>
<section id="GUID-AD4D25CA-B0BF-54BD-8029-DD495AB56C5E"><title>Fibonacci1-3:
asynchronous programming with active objects</title> <p><b>Download</b> </p> <p>Click
on the following links to download the examples: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-a87ca9bc-77dd-43b0-8e38-d16a454e2c6e.zip" scope="external"> Fibonacii1.zip </xref></p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-1f2ee4ff-787b-4240-b912-aa02651f823c.zip" scope="external">Fibonacii2.zip </xref></p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-a0979da8-ff45-4aa0-b0e0-5cc518ec328c.zip" scope="external">Fibonacii3.zip </xref></p><p>Click <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-a87ca9bc-77dd-43b0-8e38-d16a454e2c6e.html" scope="peer"> browse  Fibonacii1 </xref></p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-1f2ee4ff-787b-4240-b912-aa02651f823c.html" scope="peer">browse Fibonacii2</xref></p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-a0979da8-ff45-4aa0-b0e0-5cc518ec328c.html" scope="peer">browse Fibonacii3</xref></p> <p><b>Description</b> </p> <p>These
examples show how active objects and an active scheduler can be used to handle
asynchronous events and long-running services to maintain system responsiveness. </p><p>An
alternative solution, not using a timer, is described on <xref href="http://developer.symbian.org/wiki/index.php/Long_Running_Active_Object" scope="external">The Long Running Active Object</xref> wiki page.</p><p><b>Class
summary</b></p><p><xref href="GUID-E0B34F3E-D4C4-3232-B8B1-7DB35B454646.dita"><apiname>TRequestStatus </apiname></xref> <xref href="GUID-B4C76104-EA1B-3FC3-A31E-86A976598171.dita"><apiname> CActiveScheduler </apiname></xref> <xref href="GUID-067293BF-B28C-3CEC-92F4-1351A795EA7F.dita"><apiname>CActive </apiname></xref> <xref href="GUID-5733DF34-5B54-3044-BBED-3BFECB7ACE7A.dita"><apiname> CTimer</apiname></xref>  </p> <p><b>Security issues</b> </p> <p>The example requires no specific capabilities
in order to run - and does not demonstrate any security issues. </p> </section>
</conbody></concept>