Recent

Author Topic: How to finish visual changes before doing anything else?  (Read 3405 times)

Spoonhorse

  • Full Member
  • ***
  • Posts: 123
How to finish visual changes before doing anything else?
« on: November 28, 2021, 05:58:08 pm »
Often I want to change the appearance of a form, and then do a thing that takes a while. What invariably happens is that it half-changes the appearance of the form, and then starts doing the thing, and only finishes changing the form after I've finished the thing, and it looks clunky and bad. Is there any way to make Lazarus do what I want?

Thanks.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: How to finish visual changes before doing anything else?
« Reply #1 on: November 28, 2021, 06:38:44 pm »
You could try "doing the time-consuming thing" in a thread (not in the main GUI loop) so it does not interfere with form GUI updates.

Spoonhorse

  • Full Member
  • ***
  • Posts: 123
Re: How to finish visual changes before doing anything else?
« Reply #2 on: November 28, 2021, 08:23:13 pm »
Thanks, howardpc, but that seems a bit heavy-duty. I've never done it, but I looked it up in the Wiki and it says

"Do you need multi-threading?

If you are new to multi-threading and you only want to make your application more responsive while your application performs moderately long-running tasks, then multi-threading may be more than is required."

Now I don't even need my application to be responsive during the tasks, I can't think of any context where that would make sense, I just want it to finish one thing before starting another.

I think the thing it mentions further down in that section about using Application.ProcessMessages instead might be the lightweight alternative I'm looking for.

Spoonhorse

  • Full Member
  • ***
  • Posts: 123
Re: How to finish visual changes before doing anything else?
« Reply #3 on: November 28, 2021, 08:28:32 pm »
Yippee, that works perfectly, hurrah. It's been bugging me for ever. OK!

 

TinyPortal © 2005-2018