I'm already tired of playfoolness with it.
Run following simplified example with /opengl subsystem + threaded runtime (or without both of them, doesn't matters):
Code: Select all
EnableExplicit
; GENERIC PB RULE: ALL THE SCREEN/SPRITE OPERATIONS MUST BE DONE IN A SAME THREAD (where screen opened)
; While CloseScreen() must be called from main thread (where window events processed), wtf. Else thread locks on it
Procedure Thread(*param.integer)
While Not IsWindow(0)
Delay(1)
Wend
OpenWindowedScreen(WindowID(0), 0, 0, 200, 200, #False, 0, 0, #PB_Screen_NoSynchronization)
Define Sprite = CreateSprite(#PB_Any, 20, 20)
Repeat
If Random(2, 0) = 0 And StartDrawing(SpriteOutput(Sprite))
Box(0, 0, 20, 20, Random(255, 10)<<16 + Random(255,10))
StopDrawing()
EndIf
ClearScreen(1)
DisplaySprite(Sprite, Random(180, 0), Random(180, 0))
FlipBuffers()
Delay(16)
Until *param\i
; CloseScreen()
EndProcedure
; init
InitSprite()
OpenWindow(0, 100, 100, 200, 200, "", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
Define State ; thread reads this and quits if non-zero
Define Thread = CreateThread(@Thread(), @State)
; The problem is here.
; Main loop locks up when you try to move window using mouse (for example), or receives other events
; Putting WaitWindowEvent under mutex doesn't help
Repeat
Define E = WaitWindowEvent(1)
If E = #PB_Event_CloseWindow
State = #True
WaitThread(Thread)
CloseScreen()
End
EndIf
ForEver