emitevent.bmx 622 B

1234567891011121314151617181920212223242526
  1. SuperStrict
  2. Graphics 640,480
  3. Local myEventID:Int = AllocUserEventId("My optional event description")
  4. Local myEvent:TEvent = CreateEvent(myEventID)
  5. Local myTimer:TTImer = CreateTimer(10, myEvent)
  6. Local myQuitEventID:Int = AllocUserEventId("We want to quit now")
  7. Local myQuitEvent:TEvent = CreateEvent(myQuitEventID)
  8. Repeat
  9. WaitEvent
  10. Cls
  11. Select EventID()
  12. Case myEventID
  13. DrawText "Timer has ticked " + TimerTicks(myTimer) + " times",10,15
  14. ' exit application after 50 ticks
  15. If TimerTicks(myTimer) = 50
  16. EmitEvent(myQuitEvent)
  17. EndIf
  18. Case myQuitEventID
  19. End
  20. End Select
  21. Flip
  22. Until AppTerminate()