Symbian3/PDK/Source/GUID-8B938FEF-4D70-4589-921C-C99667193E20.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-8B938FEF-4D70-4589-921C-C99667193E20" xml:lang="en"><title><codeph>TaskSchedulerExample</codeph>:
Using Task Scheduler for Creating and Executing Tasks</title><shortdesc> This example application demonstrates the usage of the Task Scheduler
API. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section><title>Download</title><p>Click on the following link to download
the examples: </p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-c863a545-b00c-4065-8f95-04bd026abf82.zip" scope="external">TaskSchedulerExample.zip </xref></p><p>Click the following
links to view the example code.</p><p><xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-c863a545-b00c-4065-8f95-04bd026abf82.html" scope="peer">TaskSchedulerExample</xref> </p> </section>
<section><title>Purpose</title>The scheduler example has two applications;
one to schedule the tasks, and the other to run the scheduled tasks. The scheduler
application launches the application that runs the scheduled tasks, when the
tasks are due to be completed. </section>
<section>		  The scheduler application is the client of the scheduler server.
It connects and registers itself with the scheduler server using the <xref href="GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1.dita#GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1/GUID-C4EEE075-3B47-3964-AFCC-0CDF09DEDA0F"><apiname>RScheduler::Connect()</apiname></xref> and
	<xref href="GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1.dita#GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1/GUID-C19048C5-DC9F-3B8A-B4AD-02C0D943B7AC"><apiname>RScheduler::Register()</apiname></xref>  methods, respectively. While registering
itself with the scheduler server, the scheduler application provides the name
of the application that runs the scheduled tasks, along with its complete
path and its priority relative to other clients. </section>
<section>When a session with the scheduler server is started, the scheduler
creates a persistent time-based schedule using the <xref href="GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1.dita#GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1/GUID-2DBDC4BB-3E58-30E4-88A4-024F8A8514A4"><apiname>RScheduler::CreatePersistentSchedule()</apiname></xref> method.
Then, it 	adds a task to the persistent schedule using the <xref href="GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1.dita#GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1/GUID-F86AED90-2992-380B-B9FD-2763EA041FE7"><apiname>RScheduler::ScheduleTask()</apiname></xref>method. </section>
<section> The scheduler application also creates a transient time-based schedule
using the <xref href="GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1.dita#GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1/GUID-F86AED90-2992-380B-B9FD-2763EA041FE7"><apiname>RScheduler::ScheduleTask()</apiname></xref> method. The application
passes the schedule information to the method using the <xref href="GUID-EA5C4B46-AC42-3D0F-8C48-E182D0D30A12.dita"><apiname>TScheduleEntryInfo2</apiname></xref>and<xref href="GUID-ACEB1944-5B06-32AD-9D55-3F02720F261E.dita"><apiname>TTaskInfo</apiname></xref> 
  objects. It also edits the transient schedule entry to change its validity
using <xref href="GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1.dita#GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1/GUID-50B287A9-F62F-3C49-AD22-2760C96846EA"><apiname>RScheduler::EditSchedule()</apiname></xref></section>
<section>The scheduler application launches the executor application, which
runs 	 the scheduled tasks when they are due to be completed. The executor
checks whether it has the necessary capability to run the scheduled tasks
using the <xref href="GUID-049FF2D7-8444-3E87-BF2F-DD0EA9B10ED0.dita#GUID-049FF2D7-8444-3E87-BF2F-DD0EA9B10ED0/GUID-97B29D4C-FEA0-3103-BA54-31B1EA8C827C"><apiname>CScheduledTask::SecurityInfo()</apiname></xref> method. The executor
application also checks whether the Secure ID (SID) is the same as that of
the task requester, to be able to run the tasks. If these security checks
pass, the executor prints the details of the scheduled task to the console. </section>
<section>Finally, the scheduled tasks are deleted using the 	<xref href="GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1.dita#GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1/GUID-B4CECD92-82C6-3CEC-8DA6-E4D1580BEC00"><apiname>RScheduler::DeleteSchedule()</apiname></xref>	
 and 	<xref href="GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1.dita#GUID-6E138B87-ED51-3C72-9075-8D7F887FA7B1/GUID-BE934053-79EA-3101-899D-18BC91359BB7"><apiname>RScheduler::DeleteTask()</apiname></xref>methods, respectively. </section>
<section><title>Class summary </title><p>The example shows the following APIs: </p><ul>
<li><p>RScheduler</p></li>
<li><p>CScheduledTask</p></li>
<li><p>TScheduleEntryInfo2</p></li>
<li><p>TTaskInfo</p></li>
<li><p>TSchedulerItemRef</p></li>
<li><p>TSecurityInfo</p></li>
</ul></section>
<section><title>Building and configuring </title><p>To build the example:</p><ul>
<li><p>You can build the example from the Carbide.c++ IDE or the command line.</p><p>If
you use an IDE, import the bld.inf file of the example into your IDE, and
use the build command of the IDE. If you use the command line, open a command
prompt, and set the current directory to examples\SysLibs\TaskSchedulerExample
folder which contains the bld.inf file. You can then build the example with
the following build commands:</p> <p><codeblock xml:space="preserve">bldmake bldfiles
abld build winsw (For WINSCW platforms)
abld build ARMV5 (For hardware)</codeblock></p><p>for running the obtained
.exe, go to epoc32\release\winscw\udeb\ (or urel\), launch taskexecutor.exe
:</p><p><codeblock xml:space="preserve">taskexecutor.exe</codeblock></p></li>
</ul></section>
</conbody></concept>