Recent

Author Topic: An Idle Question  (Read 294 times)

JLWest

  • Full Member
  • ***
  • Posts: 225
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.
JLWEST 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 16 Gig Ram
GeForce GTX 1080 Graphics - 8 Gig 1.5 Terabyte SSD

jamie

  • Hero Member
  • *****
  • Posts: 973
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..


lucamar

  • Sr. Member
  • ****
  • Posts: 494
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 1.8.4/FPC 3.0.4 on:
(K)Ubuntu 11..16, Windows XP SP3 (Home/Prof.) and various DOS incarnations.

JLWest

  • Full Member
  • ***
  • Posts: 225
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.

 

JLWEST 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 16 Gig Ram
GeForce GTX 1080 Graphics - 8 Gig 1.5 Terabyte SSD

lucamar

  • Sr. Member
  • ****
  • Posts: 494
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 1.8.4/FPC 3.0.4 on:
(K)Ubuntu 11..16, Windows XP SP3 (Home/Prof.) and various DOS incarnations.

JLWest

  • Full Member
  • ***
  • Posts: 225
Re: An Idle Question
« Reply #5 on: December 09, 2018, 12:38:46 am »
Thank You. Yea, that sounds like a good Idea.
JLWEST 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 16 Gig Ram
GeForce GTX 1080 Graphics - 8 Gig 1.5 Terabyte SSD

Handoko

  • Hero Member
  • *****
  • Posts: 2684
  • 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