Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi thread legt programm lahm... (https://www.delphipraxis.net/36107-thread-legt-programm-lahm.html)

glkgereon 15. Dez 2004 21:39


thread legt programm lahm...
 
Liste der Anhänge anzeigen (Anzahl: 3)
hmm...ich kapiers net...

also, ich habn programm was pi [...blablabla...] berechnet

nun wollte ich das ganze zu nem thread machen

leider ist es noch im umbau....aber es funzt net...

wenn ichs starte bleibt das proggi hängen...d.h. es sieht aus wie ne endlos-schleife ohn Appl.ProceMsgs dazwischen...

ich hoffe einer kann da mal durchgucken...trotz meines im moment (wegen umbau) eher schlechtem codedesign...

GeorgPeifer 16. Dez 2004 12:44

Re: thread legt programm lahm...
 
bau 'ne bremse rein:

Code:
procedure TPiCalc.Execute;
var x, y:Extended;
begin
  SetName;
  Priority:=tpLower;
  { Thread-Code - MonteCarlo Verfahren}
  randomize;
  while not Terminated do
    begin
    x:=random;
    y:=random;
    if sqr(x)+sqr(y)<1 then inc(FPIn);
    inc(FN);
    if FOutPutLevel=3 then
      begin FPX:=x; FPY:=y; end;
    if FOutPutLevel>1 then FPi:=4*Fpin/FN;
    sleep(20); //   schlaf mal 20 Millisekunden
    end;
end;

Luckie 16. Dez 2004 13:24

Re: thread legt programm lahm...
 
Ich denke mal, es liegt an der Synchronisation mit dem Hauptthread, also mit dem Fenster.

glkgereon 16. Dez 2004 13:25

Re: thread legt programm lahm...
 
ja, das sleep hilft nix....wie würdest du das machen Luckie?

Luckie 16. Dez 2004 13:33

Re: thread legt programm lahm...
 
Ohne das TThread-Objekt der VCL. Und ein Tutorial zu Threads habe ich auf meiner Homepage.


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:46 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz