Thread waits end main process ?
Posted: Wed Nov 26, 2008 4:35 pm
Hi,
It seems, main process and thread process don't run asynchronously !
Regards
It seems, main process and thread process don't run asynchronously !
Regards
Code: Select all
Enumeration
#Win0
#Btn_Run : #Btn_Exit
#Compteur_Thread : #Compteur_Win0
EndEnumeration
Global Compteur_Thread
Procedure Add(prm)
For Compteur_Thread = 0 To 9999
SetGadgetText(#Compteur_Thread, Str(Compteur_Thread))
Next
EndProcedure
If OpenWindow(#Win0, 400, 250, 180, 160, "Fenetre 0", #PB_Window_TitleBar)
If CreateGadgetList(WindowID(#Win0))
TextGadget(#PB_Any, 20, 20, 100, 20, "Compteur Thread :")
TextGadget(#Compteur_Thread, 120, 20, 50, 20, Str(Compteur_Thread))
TextGadget(#PB_Any, 20, 50, 100, 20, "Compteur Win0 :")
TextGadget(#Compteur_Win0, 120, 50, 50, 20, Str(Compteur_Win0))
ButtonGadget(#Btn_Run, 10, 130, 70, 20, "Run")
ButtonGadget(#Btn_Exit, 100, 130, 70, 20, "Exit")
EndIf
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case #Btn_Run
ThreadID = CreateThread(@Add(), 1)
; ===> If ThreadID : WaitThread(ThreadID) : EndIf ; IF ACTIVED = FREEZ !
For Compteur_Win0 = 0 To 29999
SetGadgetText(#Compteur_Win0, Str(Compteur_Win0))
Next
Case #Btn_Exit
Event = #PB_Event_CloseWindow
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf