[DELPHI] knoppen beschikbaar houden

Pagina: 1
Acties:

  • ThePriest
  • Registratie: Mei 2000
  • Laatst online: 30-01-2024

ThePriest

the one, the only

Topicstarter
Hallo,
Nog een keer een probleempje. Ik heb een programmaatje geschreven in Delphi die erg cpu-intensief bezig is. Hij zit (na het drukken van start) in een loop die enkele minuten duurt. Nu wil ik graag de exit knop wel ten alle tijden beschikbaar houden. Weet iemand hoe je dat fixt?
Thanks!

Verwijderd

Waarom gebruik je daar niet de event handler voor.
Ik meen me te herinneren dat je onMouseClick van het 2e tabblad van die knop moet voor zien van je exit code en dan wordt je er zondermeer uit gegooit als jij dat wenst.

  • ThePriest
  • Registratie: Mei 2000
  • Laatst online: 30-01-2024

ThePriest

the one, the only

Topicstarter
Ja, da's dus 't probleem. Ik heb een form met 2 knoppen. Eentje die de rekenintensieve taak start, en eentje die Exit (close) doet. Alleen zogauw ik gestart heb doet de knop 't niet meer (niet dat 'ie disabled is, maar hij reageert gewoon niet).

  • ronaldmathies
  • Registratie: Juni 2001
  • Niet online
Dat noemen we nou programmeren met threads, ik weet alleen niet of dit binnen delphi kan (volgens mij niet :+), dan start je een thread met het process wat processor intensief is en je normale dialoogvenster blijft bruikbaar (moven, knoppen indrukken die nog actief zijn, etc.., ect...)

3015 Wp-z 5360 Wp-nno op 2 x SMA-SB3600 TL-21, Warmtepomp: ERSC-VM2CR2 / PUHZ-SHW140 YHA, WTW Q350, EV Kia Ev6 GT-Line


  • chris
  • Registratie: September 2001
  • Laatst online: 11-03-2022
Rechtstreeks uit de help van delphi (5):
TThread is an abstract class that enables creation of separate threads of execution in an application.

Unit

classes

Description

Create a descendant of TThread to represent an execution thread in a multi-threaded application. Each new instance of a TThread descendant is a new thread of execution. Multiple instances of a TThread derived class make a Delphi application multi-threaded.

When an application is run, it is loaded into memory ready for execution. At this point it becomes a process containing one or more threads that contain the data, code and other system resources for the program. A thread executes one part of an application and is allocated CPU time by the operating system. All threads of a process share the same address space and can access the processs global variables.

Use threads to improve application performance by

Managing input from several communication devices.
Distinguishing among tasks of varying priority. For example, a high priority thread handles time critical tasks, and a low priority thread performs other tasks.

Following are issues and recommendations to be aware of when using threads:

Keeping track of too many threads consumes CPU time; the recommended limit is 16 active threads per process on single processor systems.
When multiple threads update the same resources, they must be synchronized to avoid conflicts.
Most methods that access a VCL object and update a form must only be called from within the main VCL thread or use a synchronization object such as TMultiReadExclusiveWriteSynchronizer.

To create and use a new thread object:

Choose File | New | Thread Object to create a new unit that contains an object derived from the TThread class.
Define the thread objects Execute method by inserting the code that should execute when the thread is executed.

Note:See the Threads demo for multi-threading program samples.
Viel SpaB

  • ronaldmathies
  • Registratie: Juni 2001
  • Niet online
Cool, ik wist niet dat Delphi al zover gevorderd was tot volwassen worden (niet dat ik het nu wil afkraken maar ik heb vroegen alleen in pascal gewerkt, en effe in delphi) dit is in iedergeval erg goed.

3015 Wp-z 5360 Wp-nno op 2 x SMA-SB3600 TL-21, Warmtepomp: ERSC-VM2CR2 / PUHZ-SHW140 YHA, WTW Q350, EV Kia Ev6 GT-Line

Pagina: 1