Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi [TThread] - Startet nicht (https://www.delphipraxis.net/88588-%5Btthread%5D-startet-nicht.html)

xZise 17. Mär 2007 14:48


[TThread] - Startet nicht
 
Ich benutzte das erstemal das Thread-Objekt und habe schon ein Problem: Und zwar startet der Thread nicht.
Hier mal die Wichtigen Codestellen:
(Erstellen des Threads)
Delphi-Quellcode:
thread := tTest.Create(true);
thread.qdPath := qdPath;
thread.FreeOnTerminate := true;
(Starten des Threads)
Delphi-Quellcode:
tStart.Enabled := false;
thread.Resume;
(Executemethode)
Delphi-Quellcode:
procedure tTest.Execute;
begin
  ready := true;
  while ready do
  begin
    ShowMessage(''); <!--- Wird nicht angezeigt!
    if RenameFile(qdPath, qdPath + 't') then
    begin
       if newCaption <> 'a' then
      begin
        newCaption := 'a';
        Synchronize(UpdateCaption);
      end;
      RenameFile(qdPath + 't', qdPath);
    end else
    begin
       if newCaption <> 'r' then
      begin
        newCaption := 'r';
        Synchronize(UpdateCaption);
      end;
    end;
  end;
end;
(UpdateCaptionmethode)
Delphi-Quellcode:
procedure tTest.UpdateCaption;
begin
  frmUpdate.lReady.Caption := newCaption;
  frmUpdate.bUpdate.Enabled := newCaption = 'a';
end;
Er führt .Resume aus, aber den Rest nicht mehr...

PS: Keine Exceptions!

andreash 17. Mär 2007 16:22

Re: [TThread] - Startet nicht
 
Showdialog ist eine VCL-Funktion und muss mit Snychronize aufgerufen. Versuche es statt dessen mal mit Messagebox.

xZise 17. Mär 2007 16:29

Re: [TThread] - Startet nicht
 
Hmmm... Ich habs jetzt mal debugt un bekomme einen Error (juhu ^^)

Omfg... Ich hatte einmal das "override; hinter "Execute" ausgeklammert, und jetzt funzt es ... Sry für den Thread :(


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:59 Uhr.

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