[Gambas-user] How to pause/defer an event handler if a popup is open?

T Lee Davidson t.lee.davidson at gmail.com
Wed Dec 20 16:19:43 CET 2023


On 12/20/23 03:38, BB wrote:
> 
> On 20/12/23 5:28 pm, BB wrote:
>> The form in my FMain has an event handler that responds to DBus events that are raised in another process. There is also a 
>> button handler in my FMain that needs user input and an "OK" button that updates database data. That button handler needs to 
>> take precedence over the DBUS event, but I don't want to lose the updates that are caused by the other process. So how can I 
>> make the button event handler "block" the DBus event handler until it has finished?
>>
>> merry festive seasons and tia
>>
>> bruce
>>
> Okay, I turned this upside down and check for whether the FMain button form is active in the DBus event handler. In the button 
> event handler I set a global flag "UserActive=True" before the popup opens and reset it after the popup is closed. In the DBus 
> event handler I check if UserActive is true then wait 10 seconds. It seems to work but I'm not really happy, is there a better way?
> 
> b

The only thing I can think to do is to use two semaphores so the two events can be aware of each other's state. If 
UserActive=True then perhaps the DBUS event could process the updates to temporary storage. Then, when the Button event handler 
is about to finish, if TempStorageDirty=True, process the temporary storage to primary storage.

I'm assuming that the DBUS updates are database updates. And, if the two event handlers could modify the same database fields, 
that can raise an issue with data integrity; which would open a whole other can of worms.


-- 
Lee



More information about the User mailing list