Task Manager - Demos | |||||
Home | Task Manager | Simple example | Manual | Demo | Other Products |
Task Manager - a simple example
The first step is to create a TaskManager instance - Then we need to create a task to add to the task manager. Here's a simple task that prints a message to the console, waits for five seconds then writes another message to the console.
First we create a Task - Then we set the variables that determine the behaviour of our class - Now we need to create the code for our task - We add the task to the Task Manager - And now we can run the task manager - And you can see the following in the console - You can find out more about using the Task Manager classes here . There is also demonstration code and applications which you can find out about here .
TaskManager myTaskManager = new TaskManager();
Task myTask = new Task();
myTask.setSequenceNumber(1);
myTask.setName("My Task");
Runnable code = new Thread() {
public void run() {
System.out.println("Running code for My Task");
try { Thread.sleep(5000);}
catch (InterruptedException ie) {}
System.out.println("Completed code for My Task");
}
};
myTask.setCode(code);
myTaskManager.addTask(myTask);
myTaskManager.startTasks(true);
Running code for My Task
Completed code for My Task