11
What's New / Re: ScriptBasic Core Windows 32 bit - Synchronous Thread
« Last post by Support on May 25, 2021, 03:28:58 PM »This example creates a synchronous thread with the main program running a FOR/NEXT loop in unison with its thread.
sbt_main.sb
sbt_thread.sb
C:\sb_build\examples>sbc sbt_main.sb
T:1
M:1
T:2
M:2
M:3
T:3
T:4
M:4
M:5
T:5
T:6
M:6
T:7
M:7
T:8
M:8
M:9
T:9
T:10
M:10
Thread Completed
C:\sb_build\examples>
sbt_main.sb
Code: Script BASIC
- ' SBT Main
- IMPORT mt.sbi
- IMPORT sbt.sbi
- SB_ThreadStart("sbt_thread.sb", "","C:/Windows/SCRIBA.INI")
- FOR x = 1 TO 10
- PRINT "M:",x,"\n"
- sb_msSleep(20)
- NEXT
- SB_msSleep(1000)
- PRINT "Thread ",mt::GetVariable("thread_status"),"\n"
sbt_thread.sb
Code: Script BASIC
- ' SBT Main
- IMPORT mt.sbi
- IMPORT sbt.sbi
- SB_ThreadStart("sbt_thread.sb", "","C:/Windows/SCRIBA.INI")
- FOR x = 1 TO 10
- PRINT "M:",x,"\n"
- sb_msSleep(20)
- NEXT
- SB_msSleep(1000)
- PRINT "Thread ",mt::GetVariable("thread_status"),"\n"
C:\sb_build\examples>sbc sbt_main.sb
T:1
M:1
T:2
M:2
M:3
T:3
T:4
M:4
M:5
T:5
T:6
M:6
T:7
M:7
T:8
M:8
M:9
T:9
T:10
M:10
Thread Completed
C:\sb_build\examples>