Recent

Author Topic: Changing object(s) response(s) from LIFO behaviour to FIFO  (Read 4217 times)

vlado

  • Guest
Changing object(s) response(s) from LIFO behaviour to FIFO
« on: October 24, 2011, 10:49:49 am »
Hi All!

If I have a problem like this: there are lots of components on the form, let's say images. When the user clicks on images they are resizing for several seconds.

The problem is that when the user clicks on other images while the first is still resizing, the resizing of the first pauses, and the last clicked image is now resizing. This is some kind of beahviour in a LIFO way. Is there a simple way to change it to FIFO way, so the FIRST clicked image completes it's resizing process and then the SECOND one coninues?

Thanks in advance!
« Last Edit: October 24, 2011, 10:51:56 am by vlado »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4689
  • I like bugs.
Re: Changing object(s) response(s) from LIFO behaviour to FIFO
« Reply #1 on: October 24, 2011, 11:02:30 am »
If I have a problem like this: there are lots of components on the form, let's say images. When the user clicks on images they are resizing for several seconds.

The problem is that when the user clicks on other images while the first is still resizing, the resizing of the first pauses, and the last clicked image is now resizing. This is some kind of beahviour in a LIFO way. Is there a simple way to change it to FIFO way, so the FIRST clicked image completes it's resizing process and then the SECOND one coninues?

IIRC images don't resize automatically when you click on them.
It means you have created some code yourself to do it. You must change your code to make it behave like FIFO.

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

vlado

  • Guest
Re: Changing object(s) response(s) from LIFO behaviour to FIFO
« Reply #2 on: October 24, 2011, 11:17:36 am »
Quote
IIRC images don't resize automatically when you click on them.
It means you have created some code yourself to do it.
You're right.

Quote
You must change your code to make it behave like FIFO.
Hm, I know I didn't make a code to behave like LIFO, so I guess this is some kind of default Lazarus or OS (Windows 7 in my case) beahaviour?? Is there a way to change that, without putting a lot of efforts to hard-coding my code, either with threads, timer or some queue algorithm???
« Last Edit: October 24, 2011, 11:27:33 am by vlado »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12170
  • Debugger - SynEdit - and more
    • wiki
Re: Changing object(s) response(s) from LIFO behaviour to FIFO
« Reply #3 on: October 24, 2011, 11:30:25 am »
Your code probably contains Application.ProcessMessages?

Well it would have to, because without you app would become frozen for the time it takes to resize.
If it doesn't contain it, then something you call does.

Anyway, during an ProcessMessages all event (such as clicks, keys, (re-)paint) are processed.
So the 2nd click is executed, and your resize code called again.

You will have to collect and defer those calls yourself. Set a flag when you are resizing, and check when resize is called. I the flag is set, then do not resize, but increase the count of pending requests.

When finishing resize, check the count of pending requests.

 

TinyPortal © 2005-2018