Good morning! What is the best practice for checking window events and server events at the same time in the same application? I've messed with one or the other but never trying to work with both at the same time.
[Edit] I should add that in a previous application I created a thread with a repeat/forever loop and a 5 ms delay that continuously checked for network events. If that's the best way then I'll go with that again.
NetworkServerEvent and WaitWindowEvent
I would create a separate thread which detects network events and sends ato simulate a custom window event which can be handled in the window event loop. For an example take a look into an old posting from nco2k in the German forum which sends an event after counting to 100 in the separate thread (has to be adapted to PB 4): http://www.purebasic.fr/german/viewtopi ... 71&start=4
Code: Select all
PostMessage_(WindowID(0), #WM_USER+1, 0, 0)I normally do something like this:
Code: Select all
Repeat
netevent = NetworkServerEvent()
winevent = WindowEvent()
If winevent = 0 And netevent = 0
Delay(1)
Continue
EndIf
;handle events
Until <whatever>
I love Purebasic.



