How to customize a Periodic Task on Windows Phone? - windows-phone-7

I need to use a customized Periodic Task in Windows Phone 8. I have read from the below link that it runs every 30 minutes.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202942(v=vs.105).aspx
So, I am looking for an option to customize this time. Say, I want to run the Periodic Task every 15 Seconds or 20 Seconds.
Is this possible?

That is not possible. Every 30min is the lowest interval.

If you dont release the code on the market you can do this....
DateTime lastrun;
IsolatedStorageSettings.ApplicationSettings.TryGetValue<DateTime>("lastrun", out lastrun);
if (DateTime.Now.Subtract(lastrun).TotalMinutes < 60) // 60 minutes, so run every hour
{
System.Diagnostics.Debug.WriteLine("Too soon, stopping.");
NotifyComplete();
return;
}
//add proper code for removing old value, etc.
IsolatedStorageSettings.ApplicationSettings.Add("lastrun", DateTime.Now);
// Launch the task in 6 minutes
ScheduledActionService.LaunchForTest("task", TimeSpan.FromMinutes(6));

Related

What is "INTERVAL=0" means in Oracle Schedular?

My Oracle DBA have setup a task with following repeat_interval:
Start Date :"30/JAN/20 08:00AM"
Repeat_interval: "FREQ=DAILY; INTERVAL=0; BYMINUTE=15"
Can I ask what is "Interval=0" means?
Does it means this task will run daily from 8AM, and will repeat every 15 mins until success?
I tried to get the answer from Google, but what I find is what is Interval=1, but nothing for 0.
So would be great if anyone can share me some light here.
Thanks in advance!
INTERVAL is the number of increments of the FREQ value between executions. I believe in this case that a value of 0 or 1 would be the same. The schedule as shown would execute once per day (FREQ=DAILY), at approximately 15 minutes past a random hour (BYMINUTE=15, but BYHOUR and BYSECOND are not set).
Schedule has nothing to do with whether or not the previous execution succeeded or not. Start Date is only the date at which the job was enabled, not when it actually starts processing.
If you want it to run every 15 minutes from the moment you enable it, you should set as follows:
FREQ=MINUTELY; INTERVAL=15
If you want it to run exactly on the quarter hour, then this:
FREQ=MINUTELY; BYMINUTE=0,15,30,45; BYSECOND=0
If you want it to run every day at 8am, then this:
FREQ=DAILY; BYHOUR=8; BYMINUTE=0; BYSECOND=0

How to set flux cron expression for seconds to schedule an event?

I would like to schedule an event for every 15 seconds and must use flux library.
Using '0 0 +15' I'm able to set a schedule to run every 15 minutes,
However, when I tried for 15 sec my event is not picked up.
Any ideas on how I can resolve this?

run a script every 4 hours with task scheduler

I have windows 2008 task scheduler I set up a PHP script to run like this
C:\php\php.exe -f etc...
In windows task scheduler I can only schedule daily or hourly how can I configure it to run every 4 hours?
In Windows Server 2008/2008R2 you can set task to repeat every number of hours you want, corresponding drop down menu just present you with 1 hour option to select, but you can type in any number of hours you need (see screenshot below).
You could just set it up to run every hour, and at the beginning of the PHP script, check the current time, and exit if the current hour modulus 4 wasn't zero.
Where it says "repeat task every", you may also just be able to change "1 hour" to "4 hours" (it's not in the dropdown, so just type it in). You can do this in Windows 7, I'm not sure about Windows Server 2008.

quartz spring cron trigger fire immediately

I have a spring application that uses quartz cron trigger. I have given the following for frequency 0 0/20 * * * ?.....once every 20 min. But i want the first one to run immediately. Right now, when I start the application, it runs after 20 min. I was hoping it would run asap and then after 20 min.
Thanks in advance.
It sounds like you want to use an interval trigger (SimpleTrigger in Quartz can do the job).
The CronTrigger wants you to specify the minutes at which to run.
So your trigger schedule says: start at 0 minutes, and run every 20 minutes after that until the hour is over. Then start at 0 again.
But with the SimpleTrigger, you say - start now and run every 20 minutes.
Here is a tutorial on SimpleTrigger:
http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-05
Here is a tutorial on CronTrigger:
http://quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
You don't need CRON expression (and Quartz at all!) to run given code every 20 minutes. Just use fixed rate (Spring built-in):
#Scheduled(fixedRate=20 * 60 * 1000)
That's it! By default first invocation happens immediately, second after 20 minutes. Since Spring 3.2 you can even say initialDelay=10000 to run for the first time after exactly 10 seconds.
If you really want to use Quartz, check out SimpleTrigger.

Do periodicalTask every 5 minutes

I want to use PeriodicAgent and do something in backround, but the default interval for PeriodAgent is 30 mins, which is too long for my app. Is there any way (in wp7.0 or above) to change the interval?
Thank you in advance.
-Aaron
No, there is not. Even the 30 min interval is not guaranteed.

Resources