Projekt: Abakus VCL

State: All

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

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
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: (221 kB)

Sie sind nicht Angemeldet
Sie können keine Beiträge in dieses Forum schreiben.
Sie können auf Beiträge in diesem Forum nicht antworten.
Sie können Ihre Beiträge in diesem Forum nicht bearbeiten.
Sie können Ihre Beiträge in diesem Forum nicht löschen.
Sie können an Umfragen in diesem Forum nicht mitmachen.
Sie können keine Dateien in diesem Forum posten.