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 OS操作系统中实现非抢先式多任务处理的关键机制。在Symbian OS中,活动对象(Active Objects)和活动调度器(Active Scheduler)一起工作,提供了一种比传统的多线程编程更简洁、CPU...
### Symbian塞班操作系统深度解析 #### Symbian简介:智能移动终端的先驱者 Symbian操作系统,源自英国宝意昂公司(Psion)的EPOC操作系统,其设计理念强调“使用电子产品如同品尝乳酪般简单”。EPOC的命名灵感...
5. "Engine":这个名字暗示可能包含了Symbian操作系统的某个核心组件或服务的源代码,如操作系统内核、任务调度器等。 6. "GUI":图形用户界面的源代码,展示了Symbian如何实现用户交互和界面设计。 通过这些文件,...
本文将深入探讨Symbian塞班智能手机签名工具的相关知识,帮助你理解其工作原理、使用方法以及为何它对Symbian用户至关重要。 首先,我们需要了解什么是签名工具。在Symbian系统中,应用软件需要经过签名才能在设备...
本文档旨在探讨Symbian塞班软件开发工程师培训班的实施方案,从市场需求分析、人才缺口探讨、薪资待遇概述、认证考试的重要性以及认证机构的职能等方面详细解析,为有志于从事Symbian软件开发的人员提供全面的学习和...
塞班(Symbian)是一种经典的智能手机操作系统,曾经在2000年代至2010年代初广泛应用于诺基亚等品牌的手机中。它以其强大的功能和开放性吸引了大量的开发者为其开发应用程序。在塞班系统上,为了确保软件的安全性和...
Active Scheduler是Symbian OS中负责管理和调度Active Objects的组件。它维护一个任务队列,根据优先级和资源需求来决定哪些AO应该被激活。通过这种方式,调度器能够确保系统的资源得到合理分配,并且保证高优先级的...
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塞班软件破解入门资料,新手值得一看~
2. **架构**:Symbian OS采用微内核设计,核心仅包含最基本的服务,如内存管理、进程调度和中断处理,其余服务作为独立的服务器运行。这种设计提高了系统的稳定性和响应速度。 3. **兼容性**:Symbian OS支持多种...
【Symbian塞班软件开发工程师培训班实施方案】 随着信息技术的快速发展,Symbian操作系统作为曾经在智能手机领域的主导者,曾引领了移动开发的热潮。本文将深入探讨Symbian平台的开发现状、ASD(Accredited Symbian...
1. **Kernel**:Symbian操作系统的核心,负责系统调度、进程管理、内存分配等基础功能。通过源码,我们可以深入了解其如何处理多任务并行,如何有效利用有限的系统资源。 2. **Services**:Symbian的服务层提供了...
其核心包括内存管理、进程和线程调度、网络支持以及硬件抽象层等关键组件。初学者应了解这些基础,以便更好地理解代码运行的环境。 2. **EPOC C++编程** Symbian主要使用EPOC C++进行开发,这是一种特殊的C++变种...
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系统中,活动对象(Active Object)和活动调度器(Active Scheduler)是实现非抢先式多任务的关键组件,尤其在单线程环境中,它们提供了高效、简洁的编程模型。 1. **活动对象**(Active Object) - 活动...
塞班3手机360手机宝盒软件支持
活动对象是Symbian OS操作系统中的一个重要概念,它在处理异步操作时起着关键作用。活动对象的设计目的是为了管理那些非阻塞的异步函数,使得应用可以在等待某些操作完成的同时,继续执行其他任务,提高了系统的并发...
诺基亚塞班智能手机sisx,java软件.rar这个压缩包文件包含了专为诺基亚塞班(Symbian)系统设计的应用程序集合。诺基亚塞班操作系统是曾经广泛使用的智能手机平台,尤其在2000年代中期至晚期,它在移动设备市场占据着...