123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- class Main {
- static function main() {
- var event : haxe.MainLoop.MainEvent = null;
- var count = 0;
- event = haxe.MainLoop.add(function() {
- trace(count++);
- if( count == 10 ) {
- event.stop();
- trace(haxe.MainLoop.hasEvents());
- }
- });
- #if sys
- // if we don't use native timer, this should execute before
- var t = new haxe.Timer(100);
- t.run = function() {
- trace("BEFORE1");
- t.stop();
- };
- #end
- var t = new haxe.Timer(200);
- var count = 0;
- t.run = function() {
- trace("T" + count++);
- if( count == 5 )
- t.stop();
- };
- #if sys
- // if we don't use native timer, this should execute before
- var t = new haxe.Timer(100);
- t.run = function() {
- trace("BEFORE2");
- t.stop();
- };
- #end
- #if sys
- Sys.sleep(0.3);
- #end
- haxe.MainLoop.addThread(function() {
- var event : haxe.MainLoop.MainEvent = null;
- var count = 0;
- event = haxe.MainLoop.add(function() {
- trace(String.fromCharCode("A".code + count++));
- if( count == 5 ) event.stop();
- });
- #if sys
- Sys.sleep(3);
- #end
- });
- }
- }
|