Autor Beitrag
Shark
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 87

98, XP
D3, D5, D7
BeitragVerfasst: Fr 27.08.04 10:30 
Hallo

Habe mir ein kleines Vier-Gewinnt-Spiel geschrieben.
In einer Rekursion rechne einige Züge voraus und merke mir sinnvolle Züge und dessen gespiegelte Variante in einer Liste.
Nun möchte ich den Count der Liste und die verstrichne Zeit mit Hilfe eines Timers anzeigen lassen.

Ein
ausblenden Delphi-Quelltext
1:
2:
if (HashList.Count mod 100 = 0) or ((HashList.Count+1) mod 100 = 0) then
  Application.ProcessMessages;

funktioniert leider nicht richtig, da die Liste sehr unregelmäßig gefüllt wird.

Was kann ich noch tun, damit das onTimer-Ereignis in jedem Fall ausgeführt wird?
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Fr 27.08.04 13:37 
Ein Timer-Ereignis wird doch regelmäßig ausgelöst. Dann mache doch das ProcessMessages (bedingungslos) im OnTimer. Oder hab ich da jetzt was falsch verstanden?

Gruß,
Jörg
Shark Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 87

98, XP
D3, D5, D7
BeitragVerfasst: Fr 27.08.04 13:45 
Nein. Wenn die Application mit etwas anderem beschäftigt ist, wird das onTimer-Ereignis nicht ausgelöst!
patrick
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1481

WIN2k, WIN XP
D6 Personal, D2005 PE
BeitragVerfasst: Fr 27.08.04 14:09 
wenn du mehrere ereignisse nahazu parallel abarbeiten willst, solltest du sowas mit threads machen.
wie man mit threads arbeitet ist im forum ca 200000x besprochen worden
Suche in: Delphi-Forum, Delphi-Library TTHREAD
ansonsten:
der timer macht praktisch nichts anderes als eine Windows-API funktion
SetTimer und KillTimer aufzurufen. Und ist praktisch nichts anderes als ein "kleiner" thread der die zeit zählt. was gleichzeitig bedeutet, das das zählen nicht vom normalen sourceablauf abhänig ist.
wenn die ganze application ausgelastet ist, dann verzögert sich jedoch auch das aufführen des codes im timer.

ansonsten hat .Chef recht: es handelt sich um die ProcessMessage WM_Timer aber das nur am rande :D

_________________
Patrick
im zweifelsfall immer das richtige tun!!!
Shark Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 87

98, XP
D3, D5, D7
BeitragVerfasst: Fr 27.08.04 14:28 
Danke

ich werde es in einen Thread packen