Autor Beitrag
MCQ
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75

Windows 95/98/XP
Delphi 7 Etp.
BeitragVerfasst: Mi 07.01.04 17:14 
Mein Programm soll warten bis ein bestimmtes ereignis eintritt, das habe ich bisher über eine While-Schleife gelöst, alerdi ngs schnappt sich mein Programm dann sempliche Systemresourcen die es kriegen kann uns lahmt somit das System. Kann man das auch anders lösen? Wenn ja, wie ???
ErnestoChe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 528

Win 2000 pro, CRUX 2.0
Delphi 6 Pers, Open K3
BeitragVerfasst: Mi 07.01.04 18:02 
Hallo,

wie sieht denn dein bisheriger Code aus?

MFG

- Ernesto -
MCQ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75

Windows 95/98/XP
Delphi 7 Etp.
BeitragVerfasst: Mi 07.01.04 18:13 
da ich das Programm gerade erst angefangen hab, existiert kein weiterer code *g*
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mi 07.01.04 18:36 
die while schleife ist ja auch bis das ereignis eintritt eine Endlosschleife und nimmt von daher alle Systemressourcen in Anspruch...

auf welches Ereignis soll denn dein Programm reagieren?
MCQ Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75

Windows 95/98/XP
Delphi 7 Etp.
BeitragVerfasst: Mi 07.01.04 18:59 
Das Programm soll warten, bis eine bestimmte Datei existiert. Kann man das irgendwie anders lösen ?
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mi 07.01.04 20:03 
Soweit ich weiß nicht.
Aber du kannst in deine while-Schleife ein sleep(1) einfügen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
 while not_found do
begin
  not_found := check_if_there(filename);
  sleep(1);
end;

Damit veranlasst du den Scheduler von Windows deinen Prozess kurzzeitig schlafen zu legen und einem anderen Prozess die Möglichkeit zu geben, selbst was zu machen (Laut Doku sollte sleep(0) das schon machen, bei mir klappt's aber erst mit sleep(1)). Und eine so kurze Zeitspanne fällt auch nciht wieter auf, wer wartet schon eine Millisekunde auf irgendein Ereignis. ;-)

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 07.01.04 20:28 
Ich werfe einfach mal den Begriff "Thread" in die Runde.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mi 07.01.04 22:16 
Luckie hat folgendes geschrieben:
Ich werfe einfach mal den Begriff "Thread" in die Runde.

Netter Versuch, aber in diesem Fall nicht angebracht :mrgreen:
Das Problem ist nicht, daß die eigene Anwendung nicht mehr reagiert, sondern daß das ganze System nicht mehr reagiert. Lagert man das Polling anstatt in den Hauptthread in einen Nebenthread aus, besteht das Problem weiterhin.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 08.01.04 03:37 
Nö, setzt den Tread auf Idle und schon hast du die System Auslastung im Griff. Sie wird nur dann 100% betragen, wenn der Rechner sowieso keine Rechnelesitung brauch. ;)
JustusJonas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 222



BeitragVerfasst: Do 08.01.04 08:29 
Ich hab das einfach so gelöst, dass sich mein Programm wieder schließt, wenn die Datei nicht existiert!

Greetz
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 08.01.04 11:16 
Luckie hat folgendes geschrieben:
Nö, setzt den Tread auf Idle und schon hast du die System Auslastung im Griff. Sie wird nur dann 100% betragen, wenn der Rechner sowieso keine Rechnelesitung brauch. ;)

Ob das sinnvoll ist :roll:
Dan hat man mal kurz 'n Rechenlastiges Programm und dein eigenes Programm wartet 'ne halbe Ewigkeit auf die Zeitzuweisung des Schedulers...
Also ein sleep(1) wäre in diesem Fall das einfachste.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert