test2.monkey2 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Namespace threadtest2
  2. #Import "<std>"
  3. #Import "<mojo>"
  4. #Import "<thread>"
  5. #Import "threads.jpg"
  6. Using std..
  7. Using mojo..
  8. Class MyWindow Extends Window
  9. Field _image:Image
  10. Field _progress:Int
  11. Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )
  12. Super.New( title,width,height,flags )
  13. 'Create our loading thread.
  14. New Thread( Lambda()
  15. For Local i:=0 Until 1000
  16. Local image:=Image.Load( "asset::threads.jpg" )
  17. 'Update progress %
  18. _progress=i*100/1000
  19. Next
  20. Local image:=Image.Load( "asset::threads.jpg" )
  21. image.Handle=New Vec2f( .5,.5 )
  22. _image=image
  23. End ).Detach()
  24. End
  25. Method OnRender( canvas:Canvas ) Override
  26. App.RequestRender()
  27. If Not _image
  28. canvas.DrawText( "Loading...progress "+_progress+"%",Width/2,Height/2,.5,.5 )
  29. Return
  30. Endif
  31. canvas.DrawImage( _image,Mouse.Location )
  32. End
  33. End
  34. Function Main()
  35. New AppInstance
  36. New MyWindow
  37. App.Run()
  38. End