improved HelloWord service
This commit is contained in:
parent
7aa5698486
commit
644ebe1c05
@ -1,24 +1,24 @@
|
||||
package bin;
|
||||
|
||||
import kernel.service.ServiceManager;
|
||||
import kernel.log.Log;
|
||||
import kernel.Timer;
|
||||
import kernel.ps.ProcessHandle;
|
||||
import kernel.ps.Process;
|
||||
|
||||
class HelloWorldService implements Process {
|
||||
private var timer:Timer;
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function run(handle:ProcessHandle) {
|
||||
Log.debug("HelloWorldService started");
|
||||
handle.write("Hello World! Started\n");
|
||||
// this.startTimer(handle);
|
||||
var srv: HelloWorldService = ServiceManager.instance.get("HelloWorldService");
|
||||
srv.startTimer(handle);
|
||||
this.startTimer(handle);
|
||||
handle.addDeferFunc(()->{
|
||||
timer.cancle();
|
||||
});
|
||||
}
|
||||
|
||||
public function startTimer(handle: ProcessHandle) {
|
||||
new Timer(1000, function() {
|
||||
this.timer = new Timer(5, function() {
|
||||
handle.write("Hello World!\n");
|
||||
this.startTimer(handle);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user