<!DOCTYPE html> <head> <title>async Test</title> </head> <body> <h1>async Test</h1> <div id="out"> Script-Ausgabe: </div> <script src="src/async.js"></script> <script> function Output(text) { var ele = document.getElementById('out') ele.innerHTML = ele.innerHTML + '<br>' + text; } function AsyncTest() { this.MaxLoop = 0; } AsyncTest.prototype.Init = function() { Output( 'Init' ); this.MaxLoop = 5; } AsyncTest.prototype.Loop = function( Params ) { Output( 'Loop Start' ); Async.CallObj( this, this.InLoop, Params ); Params.LoopIx++; Output( 'Loop End' ); return Params.LoopIx < this.MaxLoop; } AsyncTest.prototype.InLoop = function( Params ) { Output( 'InLoop: LoopIx = ' + Params.LoopIx ); } AsyncTest.prototype.Final = function() { Output( 'Final' ); } AsyncTest.prototype.Run = function() { Output( 'Run Start' ); Async.CallObj( this, this.Init ); Async.CallObj( this, this.Loop, { LoopIx: 0 } ); Async.CallObj( this, this.Final ); Async.CallObjDefered( 1000, this, this.Init ); Async.CallObjDefered( 1000, this, this.Loop, { LoopIx: 0 } ); Async.CallObjDefered( 1000, this, this.Final ); Output( 'Run End' ); } var myAsyncTest = new AsyncTest(); myAsyncTest.Run(); </script> </body> </html>