Code: Select all
; http://library.gnome.org/devel/glib/stable/glib-The-Main-Event-Loop.html#g-timeout-add
Global stoptimer = #False
Procedure MyTimeOutFunction(*pdata.l)
Debug "hello"
If stoptimer = #False
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 300, 50, "TimeOut example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
ButtonGadget(1, 10, 10, 280, 30, "Stop timer")
EndIf
g_timeout_add_(1000, @MyTimeOutFunction(), #Null)
Repeat
If EventGadget() = 1
stoptimer = #True
DisableGadget(1, 1)
EndIf
Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf