HaxeFoundation / HaxeFoundation/haxe

haxe.Timer.delay with haxe.MainLoop

Open
#7,907 6 comments 0 reactions 0 assignees View on GitHub
bug platform-javascript
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
class Main {
public static function main():Void {
haxe.MainLoop.addThread(() -> trace("this prints"));
haxe.Timer.delay(() -> {
haxe.MainLoop.addThread(() -> trace("this does not print"));
}, 0);
}
}
```

Expected both to print, but only the first `trace` works. This is not a problem with logging – I verified by setting a value on the global object like so:

```haxe
class Main {
public static function main():Void {
js.Syntax.code("global.someTestValue = 0");
haxe.MainLoop.addThread(() -> js.Syntax.code("global.someTestValue = 1"));
haxe.Timer.delay(() -> {
haxe.MainLoop.addThread(() -> js.Syntax.code("global.someTestValue = 2"));
}, 0);
haxe.Timer.delay(() -> trace(js.Syntax.code("global.someTestValue")), 100);
}
}
```

(Outputs `1`.)

Compiled with `haxe -lib hxnodejs -main Main -js test.js` and executed with `node test.js`. Node version 8.5.0.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.