Is it better to organize all of your events in one big event loop or break them per procedure?
If every event is organized in a single loop, how do you handle logic in other procedures? For example, a settings window?
One event loop or multiple?
-
- Addict
- Posts: 1309
- Joined: Fri Aug 28, 2015 6:10 pm
- Location: Portugal
Re: One event loop or multiple?
The answer is 'it depends'.
However PB gives you lots of alternative ways you can have a single loop and you can have multiple event loops but you have to ensure only one is active at any time.
For me with a settings or options window I create the window in a module with all its procedures etc then when the main application calls the settings I disable the main window and start the code in the settings module which creates my settings window. When finished I close the settings and reactivate the main window.
There are times when you may need two or more windows open and active at the same time in this case I choose one windows event loop and you can use the EventWindow() to send the event to the correct window to be processed.
Clear as mud?
However PB gives you lots of alternative ways you can have a single loop and you can have multiple event loops but you have to ensure only one is active at any time.
For me with a settings or options window I create the window in a module with all its procedures etc then when the main application calls the settings I disable the main window and start the code in the settings module which creates my settings window. When finished I close the settings and reactivate the main window.
There are times when you may need two or more windows open and active at the same time in this case I choose one windows event loop and you can use the EventWindow() to send the event to the correct window to be processed.
Clear as mud?
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Re: One event loop or multiple?
Always use only one event loop and distribute from it. Otherwise you may lose an event that you still need. If a second window is opened, prevent the window from opening again. Either by IsWindow() or the Lock function. DisableMenu(), DisableButton()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: One event loop or multiple?
Thanks, all. This is helpful.