Project: Abakus VCL
Question

State: All

User infoMark DiVecchio
21.Jul.15 17:22
Subject:
Sliders and Re-entrancy

Description:
I use the TAbVSlider in my application. The event handler for OnValueChange that I have takes about 1 second to execute. When I slide the control using the mouse or the up/down arrow keys, the event handler is called many, many times in a second. The code I wrote in the event handler is re-entered many times before it has completed the processing for the first event. The code is not re-entrant and gets very confused.

I need to prevent the event handler from being called again until it is has completed processing the previous event. At the same time, I have to ensure that event handler is called by the final change so that the Value in the slider was processed by my OnValueChange code.


User infoadmin
23.Jul.15 14:10
Comment:
Hi,
i don't know your application but may you can use the OnValueChanged Event instead of the OnValueChange. A small demo you will find attached.

Another good way to prevent courious behavior is to create a global "busy"-flag which you check at begin of the slow Routine, if the flag is checked then Exit this routine.
Direct after the check you set this bit true and at end of this Routine you reset this flag.

Files:
OnValueChange.zip (221 kB)


You are not logged-in
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot upload files in this forum