Task Scheduler crashes

Login to reply to this topic.
Fri, 2007-11-16 14:14
Joined: 2007-11-16
Forum posts: 5

Hi, all !

I would like to launch one program at a fixed hour each day.
For that, I'm using RScheduler.

However, when launching the application on an N80, ScheduleTask returns -14 (KErrInUse)
At the same time I'm getting the following message :

Appl. fermée: (Application closed)
!TaskScheduler
USER 0

With subsequent launches of the application, RScheduler::Connect() fails with -1 (KErrNotFound), and I get the same message again.

I'm also getting that message when starting the phone, while and whenever the application is installed.

So my guess is that my application somehow corrupts the TaskScheduler database.

Here is the incrimined part of my code (error checking removed for brievity) :

void CMyProgramAppUi::ScheduleSomeTask()
{
        TInt       errCode;
        RScheduler scheduler;

        _LIT(exeFileName,"C:\\sys\\bin\\MyProgram.exe");
        TFileName fileName(exeFileName);

        errCode = scheduler.Connect();
        errCode = scheduler.Register( fileName, CActive::EPriorityStandard );

        _LIT(startTimeStr,"000000.");
        TTime lTime(startTimeStr); // Could have used TDateTime

        TTsTime startTime;
        startTime.SetUtcTime( lTime );

        TScheduleEntryInfo2 lScheduleInfo2(startTime, EHourly, 24, KMaxTInt);

        CArrayFixFlat<TScheduleEntryInfo2>* array;
        array = new (ELeave) CArrayFixFlat<TScheduleEntryInfo2>(1);
        array->AppendL( lScheduleInfo2 );

        TSchedulerItemRef itemRef;
        errCode = scheduler.CreatePersistentSchedule( itemRef, *array );

        _LIT(taskNameStr,"Browser");
        TTaskInfo taskInfo;
        taskInfo.iTaskId = 0;
        taskInfo.iName = taskNameStr;
        taskInfo.iPriority = CActive::EPriorityStandard;
        taskInfo.iRepeat = 1;

        HBufC* passData = NULL;
        passData = KNullDesC().Alloc();

        // Crashes TaskScheduler
        errCode = scheduler.ScheduleTask( taskInfo, *passData, itemRef.iHandle);

        scheduler.Close();
}

Does anyone have any idea about what's wrong ?

Thanks in advance.

  • Login to reply to this topic.