improved HelloWord service

This commit is contained in:
Djeeberjr 2023-06-07 20:09:54 +02:00
parent 7aa5698486
commit 644ebe1c05

View File

@ -1,24 +1,24 @@
package bin; package bin;
import kernel.service.ServiceManager;
import kernel.log.Log;
import kernel.Timer; import kernel.Timer;
import kernel.ps.ProcessHandle; import kernel.ps.ProcessHandle;
import kernel.ps.Process; import kernel.ps.Process;
class HelloWorldService implements Process { class HelloWorldService implements Process {
private var timer:Timer;
public function new() {} public function new() {}
public function run(handle:ProcessHandle) { public function run(handle:ProcessHandle) {
Log.debug("HelloWorldService started");
handle.write("Hello World! Started\n"); handle.write("Hello World! Started\n");
// this.startTimer(handle); this.startTimer(handle);
var srv: HelloWorldService = ServiceManager.instance.get("HelloWorldService"); handle.addDeferFunc(()->{
srv.startTimer(handle); timer.cancle();
});
} }
public function startTimer(handle: ProcessHandle) { public function startTimer(handle: ProcessHandle) {
new Timer(1000, function() { this.timer = new Timer(5, function() {
handle.write("Hello World!\n"); handle.write("Hello World!\n");
this.startTimer(handle); this.startTimer(handle);
}); });