Restored from previous forum. Originally posted by Danilo.
Your program is ending right after
starting the thread.
If the program is ended, the threads are
also destroyed.
Try this, so you have 10 seconds:
Code: Select all
Structure DATOS
name.s
lastname.s
country.s
numid.l
EndStructure
Procedure genera(*myvar.DATOS)
MessageRequester("01",*myvar\name,0)
MessageRequester("02",*myvar\lastname,0)
MessageRequester("03",*myvar\country,0)
MessageRequester("04",Str(*myvar\numid),0)
EndProcedure
myvar.DATOS
myvar\name = "MyName"
myvar\lastname = "MyLastName"
myvar\country = "MyCountry"
myvar\numid = 101
ThreadID = CreateThread(@genera(),@myvar)
Delay(10000)
End
See what i mean ??
There _should_ be a command to check if the thread
is still running (
IsThread() / IsThreadRunning() ),
but i cant find it in PureBasic.
It makes more sense with Windows GUI interface:
Code: Select all
Structure DATOS
name.s
lastname.s
country.s
numid.l
EndStructure
; Thread
Procedure Scroller(*myvar.DATOS)
TextLength = Len(*myvar\name)
Repeat
If Scroller_Position < TextLength + 1 And Scroller_Direction = 0
Scroller_Position+1
Else
Scroller_Direction = 1
Scroller_Position-1
If Scroller_Position = 0 : Scroller_Direction = 0 : EndIf
EndIf
TEMP$ = Right(*myvar\name,Scroller_Position)
SetWindowText_(*myvar\numid, TEMP$)
Delay(200)
ForEver
EndProcedure
myvar.DATOS
myvar\name = "MyName"
myvar\numid = OpenWindow(0, (GetSystemMetrics_(#SM_CXSCREEN)-400)/2,(GetSystemMetrics_(#SM_CYSCREEN)-100)/2, 400, 100, #PB_Window_SystemMenu,"")
CreateThread(@Scroller(),@myvar)
Repeat:Until WaitWindowEvent() = #PB_EventCloseWindow
So you can see better that it works...
cya,
...Danilo
(registered PureBasic user)
Edited by - Danilo on 15 August 2002 06:15:21