With this concept can you schedule and execute periodically your jobs.
The timer task having an offset (miliseconds when you want to start the
task) and a period parameter (milliseconds between the task executions).
# The timer is Singleton, you have only one instance on your terminal
$y=Timer.getInstance
# Starting after 10 sec (from after the mn8 script init.)
# and every 30 sec will execute the "Google ..." script
Timer.addTask(10000, 30000, "Google rsearch Antal Attila atech")
# Starting after 1 min (from after the mn8 script init.)
# and every 10 min will execute the method onlytest from the
# Test concept with parameter "Helo World!"
$ser typeof Series
$ser.add("Helo World")
Timer.addTask(60000, 600000, "Test.onlytest", $ser)
# looking after my timer tasks
print $y.toXML
# getting the tasks into the series
$tasks = Timer.getTasks
# Ugly task with id=1, I remove it
Timer.removeTask(1)
# How many tasks I have?
print "" + Timer.getTasks@length
# Be happy I starting the scheduler
Timer.start
# The system is hanging up and holds the scheduler to work
System.pause(0)
# Is something working bad or need to shut down the scheduler
Timer.stop
Label: | task |
Type: | Series |
Is Static: | false |
Is Hidden: | false |
Is Multi: | false |
Show Empty: | true |
Task element to hold informations with its attributes
Parameters: |
$offs : | The offset value |
$period : | The periods value |
$target : | Execution string in order by ConceptName followed by
it self attributes |
|
Exceptions: |
errorAddingTask :
(Error) |
If unable to add task to the Timer concept. |
Adding task into your tasks.
Timer.addTask(10000, 60000, "Google rsearch regexp syntax flags")
# This will execute the "Google rsearch ..." command every
# minute starting on 10 sec after system init
Parameters: |
$offs : | The offset value |
$period : | The periods value |
$target : | Execution string like an mn8 static method call,
Concept.method |
$params : | A series for method parameters |
|
Exceptions: |
errorAddingTask :
(Error) |
If unable to add task to the Timer concept. |
Adding task into your tasks.
$ser typeod Series
$ser.add("Hello World")
Timer.addTask(10000, 60000, "Echo.echoString", $ser)
# This will execute the "Echo echoString" command with
# a "Hello World" parameter, every min starting 10 sec after
# system ini
The timer concept is Singleton, with this method you can get an instance.
Timer.addTask(60000, 600000, "Google rsearch regexp syntax flags")
Timer.getInstance
-- the result is --
Timer
tasks
task
id: 1 offset:60000 period:600000 CommandString: Google rsearch regexp syntax flags
Returns all the tasks.
Timer.addTask(60000, 600000, "Google rsearch regexp syntax flags")
Timer.addTask(10000, 600000, "Test.testmethod", $ser)
Timer.getTasks
-- the result is --
task
id: 1 offset: 60000 period: 600000 CommandString: Google rsearch regexp syntax flags
task
id: 2 offset: 10000 period: 600000 CommandString: Test.testmethod
Parameters: |
$taskId : | Task id, what returns the addTask method |
|
Remove the specified task.
Timer.addTask(10000, 600000, "Google rsearch regexp syntax flags")
Timer.addTask(1, 3600000, "Google rsearch Gnome 2.0 distribution")
Time.removeTask(1)
Timer.getTasks
-- the result is --
task
id: 2 offset: 1 period: 3600000 CommandString: Google rsearch Gnome 2.0 distribution
Exceptions: |
onStartException :
(Error) |
If the scheduler can't be started. |
Starting the scheduler.
Timer.addTask(10000, 600000, "Google rsearch regexp syntax flags")
Timer.addTask(1, 3600000, "Google rsearch Gnome 2.0 distribution")
Timer.start
Stops the scheduler.
Timer.stop