I'm trying to port an application from Windows to Linux. I'm having trouble with threads, though I enabled ThreadSafe compiling.
Here is a small example code:
Code: Select all
Procedure About(*dummy)
MessageRequester("Requester","Click ok")
EndProcedure
OpenWindow(0, 0, 0, 220, 70, "Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, 10, 10, 200, 20, "Click me")
TextGadget(2, 10, 40, 200,20,"")
date_old=Date()
Repeat
Event = WaitWindowEvent(100)
If Event=#PB_Event_Gadget And EventGadget()=1
CreateThread(@About(),0)
EndIf
date_new=Date()
If date_old<>date_new:date_old=date_new:SetGadgetText(2,FormatDate("%hh:%ii:%ss",date_new)):EndIf
Until Event = #PB_Event_CloseWindow
Using windows, the program runs fine.
With linux (tested with 32bit), the program crashes or hangs when you click the button.
Am I missing something here? Is MessageRequester not thread safe?
Any simple workarounds are also welcome.
I know I could just not use MessageRequester but create a new window and handle everything from the main thread, but that is somewhat more complicated than this simple solution that works with windows. Ideally, it should work the same with linux.
--manu