From 644ebe1c05efc2d4859b36ad42d525552d7d6b06 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Wed, 7 Jun 2023 20:09:54 +0200 Subject: [PATCH] improved HelloWord service --- src/bin/HelloWorldService.hx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bin/HelloWorldService.hx b/src/bin/HelloWorldService.hx index 7cfd0a2..6708f6b 100644 --- a/src/bin/HelloWorldService.hx +++ b/src/bin/HelloWorldService.hx @@ -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); });