×
Namespaces

Variants
Actions

如何调度基于DLL或EXE的任务

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
huwell 在 29 Jun 2007 创建
最后由 hamishwillee 在 15 Dec 2011 编辑
  • 开发伙伴平台:

60系列开发平台 1.0/2.0


  • 说明:

使用RScheduler类调度基于DLL或EXE的任务需要如下处理: 在模拟器上调度基于DLL的任务,需要完成:

//MyDll.cpp
LOCAL_D TInt StartDLL(TAny* aParam)
{
CMyDll* self = new(ELeave) CMyDll;
self->Test();
return(KErrNone);
}
TInt CMyDll::Test()
{
return KErrNone;
}
EXPORT_C TThreadFunction ThreadFunction()
{
// Ordinal one export that returns the function
// which extracts the pseudo-command line
// under WINS, this is passed as thread data).
return StartDLL;
}
GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
{
return(KErrNone);
}


传递到StartDLL中的参数按如下方法使用以便生成SCheduledTask对象

TFileName* fileName = reinterpret_cast<TFileName*>(aParam);
CcFileStore* store = CDirectFileStore::OpenLC(iFsSession, fileName, EFileRead);
RStoreReadStream instream;
instream.OpenLC(*store, store->Root());
// Get task count
TInt count = instream.ReadInt32L();
__ASSERT_ALWAYS(count > 0, Panic(ETaskExePanicNoScheduledTasks));
for (TInt i=0;i<count;i++)
{
CScheduledTask* task =
CScheduledTask::NewLC(instream);
}


在目标设备上调度基于EXE的任务,可以如下处理:

GLDEF_C TInt E32Main()
{
TBuf<256> cmd;
RProcess().CommandLine(cmd);
return Test(cmd);
}
LOCAL_C TInt Test(TDesC& aTaskDataFile)
{
// Extract scheduled tasks as shown above.
}
This page was last modified on 15 December 2011, at 13:10.
36 page views in the last 30 days.
×