Recent

Author Topic: An Idle Question  (Read 2671 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1293
An Idle Question
« on: December 08, 2018, 08:52:47 pm »
Am I the only customer you guys got? You guys are going to have to come up with more beginners. I don't think I can keep you that busy. Well maybe I can.

I have a form with a 5 listboxes that I load out of the FormShow event.

Then the user has to press one of several buttons to do various process.

After loading the last listbox out of FormShow is their a command I can issue that puts the program in idle or something.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: An Idle Question
« Reply #1 on: December 08, 2018, 09:19:56 pm »
I guess If the user does not interact with it then it is considered inactive ?

But if you want to do things like send the app the back of all others you can.

you have "SendToBack", "BringTofront"

If you want to minimize the form to the taskbar you can do this..

WindowStte := wsMinimized;

that works for the main form so the whole app gets minimized.

Things to play with..

The only true wisdom is knowing you know nothing

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: An Idle Question
« Reply #2 on: December 08, 2018, 09:38:58 pm »
Modern OSs and modern applications are able to manage their time quite well. After your code is executed your applicaiton will look to the message queue and enter, by itself, an idle state if there's nothing there for it to do; the OS, for its part, will (try to) make sure your program doesn't consume an inordinate amount of time doing its thing and will stop your application until there's something for it to do.

Of course, all is not as simple: this is just the ultra-very schematic explanation. The point is that your application will probably be idle more time than working already. So ...

What is it exactly you want to do?
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: An Idle Question
« Reply #3 on: December 08, 2018, 11:05:37 pm »
Maybe I didn't explain myself very well.
Out of the procedure FormShow I do the following;

procedure TFMain.FormShow(Sender: TObject);
Begin
Load ICOAS
LoadRoutes
Load Airports
End;

The process flow is after Load ICOAS it comes back and executes LoadRoutes
returns and executes LoadAorports comes back and it now on the end statement.


Then the form appears.

Can I assume it waiting for a button press or something from the user.

I assume there is nothing I can code after Load Airports to tell the program to go idle or park until called.

 

FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: An Idle Question
« Reply #4 on: December 08, 2018, 11:15:13 pm »
Can I assume it waiting for a button press or something from the user.

Yes, of course. Once all the initialization is done, the form shown, etc. the program does nothing but wait for the user to do something--unless you have an active timer or thread os something like that.

Quote
I assume there is nothing I can code after Load Airports to tell the program to go idle or park until called.

Not really, unless by "park" you mean going to sleep() or something like that. If you mean just "idle, waiting for events" then the program is already in that state. You need do nothing more.

Incidentally, why don't you do all your LoadXXX in the OnCreate event? Unlike OnShow, OnCreate is guaranteed to be called just once in the life of the form, and by then all the design-time controls have been created already.
« Last Edit: December 08, 2018, 11:19:26 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: An Idle Question
« Reply #5 on: December 09, 2018, 12:38:46 am »
Thank You. Yea, that sounds like a good Idea.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: An Idle Question
« Reply #6 on: December 09, 2018, 03:04:39 am »
This wiki page may help you better understand event order:
http://wiki.freepascal.org/Event_order

And try this RAW's demo code:
http://forum.lazarus.freepascal.org/index.php/topic,37600.msg253236.html#msg253236

 

TinyPortal © 2005-2018