Asynchronous Services Example Codes

Explains how to use asynchronous requests.

SingleRequest: asynchronous programming without active objects

Download

Click on the following link to download the example: SingleRequest.zip

Click on the following link to download additional file: CommonFramework.zip

Click browse SingleRequest to view the example code.

Click browse CommonFramework to view the additional file.

Click on the below link for S60 Example which demonstrates Asynchronous requests ClientServerAsync .zip .

Browse the S60 files. ClientServerAsync .

Description

This example shows how to issue and wait for a single request.

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 without active objects.

This example does not use active objects deliberately.

Class summary

TRequestStatus

Security issues

The example requires no specific capabilities in order to run - and does not demonstrate any security issues.

WaitLoop: asynchronous programming without active objects

Download

Click on the following link to download the example: Waitloop.zip

Click on the following link to download additional file: CommonFramework.zip

Click browse Waitloop to view the example code.

Click browse CommonFramework to view the additional file.

Description

This example shows how a wait loop can be used to identify and handle a completed request.

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 without active objects.

This example does not use active objects deliberately.

Class summary

TRequestStatus

Security issues

The example requires no specific capabilities in order to run - and does not demonstrate any security issues.

RealLifeWaitLoop: asynchronous programming without active objects

Download

Click on the following link to download the example: RealLifeWaitLoop.zip

Click on the following link to download additional files: CommonFramework.zip

Click browse RealLifeWaitLoop to view example code.

Click browse CommonFramework to view the additional file.

Description

As with the WaitLoop 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.

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 without active objects.

This example deliberately does not use active objects.

Class summary

TRequestStatus

Security issues

The example requires no specific capabilities in order to run - and does not demonstrate any security issues.

RunComplete: asynchronous programming with active objects

Download

Click on the following link to download the example: RunComplete.zip

Click on the following link to download additional files: CommonFramework.zip

Click browse RunComplete to view the example code.

Click browse CommonFramework to view the additional file.

Description

The example shows how active objects and an active scheduler can be used to handle asynchronous events. Compare this with the following examples; SingleRequest, WaitLoop and RealLifeWaitLoop.

It demonstrates a single CMessageTimer active object which runs until completion.

Class summary

TRequestStatus CActiveScheduler CActive CTimer

Security issues

The example requires no specific capabilities in order to run - and does not demonstrate any security issues.

AcceptInput1-2: asynchronous programming with active objects

Download

Click on the following links to download the examples:

AcceptInput1.zip

AcceptInput2.zip

Click on the following link to download additional files: CommonFramework.zip

Click on the following links to view the examples:

browse AcceptInput1

browse AcceptInput2

Click browse CommonFramework to view the additional file.

Description

These examples show how active objects and an active scheduler can be used to handle asynchronous events.

They demonstrate a single CKeyMessengerProcessor active object (derived from class CActiveConsole), which accepts input from keyboard, but does not print it. This object contains a CMessageTimer object which it activates if the user inputs the character "m" and cancelled if the user inputs "c".

Class summary

TRequestStatus CActiveScheduler CActive CTimer

Security issues

The example requires no specific capabilities in order to run - and does not demonstrate any security issues.

AcceptPrintInput: asynchronous programming with active objects

Download

Click on the following link to download the example: AcceptPrintInput.zip

Click on the following link to download additional files: CommonFramework.zip

View the source code browse AcceptPrintInput. View the additional file: browse CommonFramework.

Description

This example demonstrates how to accept and print keyboard input to a console using active objects.

The example implements a class called CWriteKeyProcessor which is an active object that requests and handles keyboard input in its ProcessKeyPress() 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.

Class summary

CActiveScheduler CActive CTimer

Security issues

The example requires no specific capabilities in order to run - and does not demonstrate any security issues.

Fibonacci1-3: asynchronous programming with active objects

Download

Click on the following links to download the examples: Fibonacii1.zip

Fibonacii2.zip

Fibonacii3.zip

Click browse Fibonacii1

browse Fibonacii2

browse Fibonacii3

Description

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.

Class summary

TRequestStatus CActiveScheduler CActive CTimer

Security issues

The example requires no specific capabilities in order to run - and does not demonstrate any security issues.