; SetJobProgress Example ; ---------------------- ; Requires Extended mode. Graphics 640,480,0,2 SetBuffer BackBuffer() ; The worker builds a level in three named stages Worker Function BuildLevel(inputBank) For phase=1 To 3 If phase=1 Then stage$="Carving rooms" If phase=2 Then stage$="Digging corridors" If phase=3 Then stage$="Hiding treasure" For toil=1 To 10 ; Busy work standing in for real level generation For dig=1 To 800000 noise#=Sin(dig) Next ; Publish an advisory done/total/stage snapshot for the main thread SetJobProgress (phase-1)*10+toil,30L,stage Next Next Return CreateBank() End Function job=StartJob(BuildLevel) While Not KeyDown(1) Cls ; Read back the snapshots the worker published with SetJobProgress progress=JobProgress(job) Color 60,60,80 Rect 70,220,500,24,True Color 90,200,120 Rect 70,220,progress*500/1000,24,True Color 255,255,255 Rect 70,220,500,24,False Text 0,0,"Esc: exit" Text 70,190,"Worker publishing SetJobProgress done,30L,stage$ snapshots" Text 70,254,"Done "+JobProgressDone(job)+" of "+JobProgressTotal(job)+" Stage: "+JobProgressText(job) If JobFinished(job) Then Text 70,274,"Level complete!" Flip Wend FreeJob job End