RScheduler
Purpose
RScheduler is a client-side interface to the Task Scheduler.
UseCase
This class can be used for scheduling a task(s), which should be running at regular interval of time for example some Server Application.
We will be specifying the time for the task to be started and also the periodical check say Hourly,Daily,Monthly or yearly from the start time.If that task doesnt exist at that time mentioned, then Scheduler will start this task.
Example Codes
Header Files
1.#include <csch_cli.h> // RScheduler
2.#include <schinfo.h> // TScheduleEntryInfo, TSchedulerItemRef,TTaskInfo
Libraries
schsvr.lib
Capabilities
None
The following are the steps followed to schedule a task:
1.Connect to the Task Scheduler.
2.Register to the Task Scheduler.
3.Create a time based Schedule i.e., information about the Start and End Time.
4.Schedule the Task i.e., Add this to the Schedule.
5.Disconnect to the Task Scheduler.
Connecting to the Task Scheduler
1.The following code snippet is used to Connect to the Task Scheduler:
RScheduler scheduler;
User::LeaveIfError(scheduler.Connect());
Register to the Task Scheduler
2.The following code snippet is used to Register to the Task Scheduler:
TFileName fileName;
fileName = _L("ExeName_to_be_Scheduled.exe");
User::LeaveIfError(scheduler.Register( fileName, CActive::EPriorityStandard ));
Create a time based Schedule i.e., information about the Start and End Time
3.The following code snippet is used to Create a time based Schedule:
First we set the Time when the Scheduler should start:
3.a.The following code snippet is used to retrieve the current time:
TTime lTime;
lTime.HomeTime();
TTsTime startTime;
startTime.SetLocalTime( lTime );
3.b.The following code snippet is used to set Start Time for the Scheduler:
TScheduleEntryInfo2 lScheduleInfo2(startTime, EHourly, 1, KMaxTInt);
This will be scheduling the task every one hour with maximum validity period.
3.c.The following code snippet is used to Add the created ScheduledInfo into Scheduled entries:
CArrayFixFlat<TScheduleEntryInfo2>* array;
array = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(1);
array->AppendL( lScheduleInfo2 );
TSchedulerItemRef class is used to uniquely identify the schedule.
TSchedulerItemRef itemRef;
User::LeaveIfError(scheduler.CreatePersistentSchedule( itemRef, *array ));
On execution of the above code, itemRef contains the Id(iHandle) for this Schedule using which we can refer this schedule in the future.
Schedule the Task i.e., Add this to the Schedule
4.The following code snippet is used to Schedule the Task:
TTaskInfo contains the information regarding the Task like its Id,Name,Priority,Repeater.
We pass the Schedule Id to the ScheduleTask().
TName taskName = _L("Test");
TTaskInfo taskInfo;
taskInfo.iTaskId = 0;
taskInfo.iName = taskName;
taskInfo.iPriority = CActive::EPriorityStandard;
taskInfo.iRepeat = -1;
HBufC* passData;
passData = KNullDesC().AllocL();
User::LeaveIfError(scheduler.ScheduleTask( taskInfo, *passData, itemRef.iHandle));
Disconnect to the Task Scheduler
5.The following code snippet is used to Disconnect from the Task Scheduler:
scheduler.Close();
The following code snippet is used to query the information regarding a particular schedule:
TScheduleState2 lSchState;
CArrayFixFlat< TScheduleEntryInfo2 >* entryArray = new (ELeave)
CArrayFixFlat<TScheduleEntryInfo2>(1);
CArrayFixFlat< TTaskInfo >* tskInfoArray = new (ELeave)
CArrayFixFlat< TTaskInfo >(1);
TTsTime dueTime;
//We pass the Id of the Schedule to this API using iHandle member of
//TSchedulerItemRef class
User::LeaveIfError(scheduler.GetScheduleL(itemRef.iHandle,
lSchState, *entryArray, *tskInfoArray, dueTime));
TBuf<20> lBuf;
lBuf = lSchState.Name();
CEikonEnv::Static()->InfoWinL(_L("Name "), lBuf);
if ( lSchState.Persists() != 0 )
{
CEikonEnv::Static()->InfoWinL(_L("Persists"), _L("True"));
}
else
{
CEikonEnv::Static()->InfoWinL(_L("Persists"), _L("False"));
}
if ( lSchState.Enabled() != 0 )
{
CEikonEnv::Static()->InfoWinL(_L("Enabled"), _L("True"));
}
else
{
CEikonEnv::Static()->InfoWinL(_L("Enabled"), _L("False"));
}
TTime schLocalTime = dueTime.GetLocalTime();
The following code snippet is used to query the information regarding a particular task associated with a schedule:
TTaskInfo taskInfoRet;
TSchedulerItemRef itemRefRet;
startTime taskDueTime;
TInt dataSize;
User::LeaveIfError(scheduler.GetTaskDataSize(taskInfo.iTaskId, dataSize );
HBufC* lDataBuf = HBufC::NewL(dataSize);
TPtr16 ptr=lDataBuf->Des();
//We pass the Id of the Task to this API using iTaskId member of TTaskInfo class
User::LeaveIfError(scheduler.GetTaskInfoL(taskInfo.iTaskId, taskInfoRet,
ptr, itemRefRet,taskDueTime ));
CEikonEnv::Static()->InfoWinL(_L("Task Name"), taskInfo.iName);
TBuf<5> repeatBuf;
repeatBuf.AppendNum(taskInfo.iRepeat);
CEikonEnv::Static()->InfoWinL(_L("Task repeat"), repeatBuf);
TTime taskLocalTime1 = taskDueTime.GetLocalTime();
The following code snippet is used to delete a specified task:
User::LeaveIfError(schedule.DeleteTask(taskInfo.iTaskId));
The following code snippet is used to delete a specified Schedule:
//Note that all the Tasks associated with this Scheduler must be deleted
// before executing this code.
User::LeaveIfError(schedule.DeleteDeleteSchedule(itemRef.iHandle));
Example Project
File:RScheduler Example.zip
相关推荐
Symbian塞班操作系统的介绍以及应用
Symbian塞班软件破解入门资料,新手值得一看~
Symbian(塞班)智能手机应用技巧十二讲
塞班3手机360手机宝盒软件支持
塞班智能手机,Symbian系统智能手机签名工具,轻松安装各种软件
塞班系统 Symbian 操作系统是Symbian公司为手机而设计的操作系统,它包含联合的数据库、使用者界面架 构和公共工具的参考实现,它的前身是Psion的EPOC。 目录 Symbian简介 1. 概述 2. 第一款采用Symbian OS的手机 3....
本书旨在帮助读者编写良好的基于Symbian OS的C++程序。全书共分为21章,分别介绍了Symbian OS中的类命名约定、异常退出、清除栈、两段构造、描述符、良好的描述符风格、动态的数组与缓冲区、使用活动对象的事件驱动...
symbian塞班软件开发工程师培训班实施方案.doc
Symbian S60 V3软件Symbian S60 V3软件Symbian S60 V3软件Symbian S60 V3软件Symbian S60 V3软件Symbian S60 V3软件Symbian S60 V3软件Symbian S60 V3软件打包下载 我佛痴悲 石祖江Symbian S60 V3软件打包下载 我佛...
塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名工具塞班签名...
Symbian S60 V3软件打包下载Symbian S60 V3软件打包下载Symbian S60 V3软件打包下载Symbian S60 V3软件打包下载Symbian S60 V3软件打包下载Symbian S60 V3软件打包下载Symbian S60 V3软件打包下载Symbian S60 V3软件...
symbian java 开发环境 nokia 开发 symbian java 开发环境 symbian java 开发环境 symbian java 开发环境 symbian java 开发环境
推荐-symbian塞班软件开发工程师培训班实施方案 精品.pdf
塞班证书生成器,可用于在线生成Symbian证书
可以随意的对塞班s60v3以上的软件进行签名,去签名。操作简单。绿色免安装
SymbianOS概述 SymbianSDK及其开发环境 Symbian软件开发
塞班插件塞班插件
Symbian OS 架构介绍
symbian平台安全性symbian平台安全性symbian平台安全性symbian平台安全性symbian平台安全性symbian平台安全性
Be My Love塞班S60V3主题Be My Love塞班S60V3主题Be My Love塞班S60V3主题Be My Love塞班S60V3主题Be My Love