Autor Beitrag
Xenar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: Sa 30.04.05 18:15 
Hallo,

mit folgender prozedur starte ich ein Thread:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.ButtonClick(Sender: TObject);
  var
    BeispielThread: TBeispielThread;
  begin
    Label1.Font.Color:= ClYellow;
    Label1.Caption:= 'Beispielthread läuft';
    BeispielThread:= TBeispielThread.Create(False);
    BeispielThread.FreeOnTerminate:= True;
  end;

Nun will ich aus einer anderen Prozedure heraus diesen und alle anderen Threads abbrechen.
Dabei weiß ich aber nicht ob der Thread läuft oder nicht.
Jeder Thread hat bei mir eine eigene Unit. Die obige prozedur und die, aus der abgebrochen werden soll, sind in unit1.

:?

Ciao Xenar

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconKlabautermann: Topic aus Sonstiges verschoben am So 01.05.2005 um 15:19
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Sa 30.04.05 18:20 
Da gibt es verschieden Lösungswege. Einer wäre z.B. das Ereignis OnTerminate von TThread auszuwerten.

_________________
Ciao, Sprint.
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: Sa 30.04.05 18:30 
Gibt es ein kurzen Befehl der alle Threads abbricht? Es muss dabei aus den Threads nicht gesichert werden?
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Sa 30.04.05 18:35 
Du kannst z.B. die Methode Terminate von TThread aufrufen. Dann musst du innerhalb deines Thread's die Variable Terminated auswerten und den Thread verlassen. Oder halt brutal mit der Win32 API TerminateThread.

_________________
Ciao, Sprint.
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 01.05.05 14:05 
Wie lautet den der Befehl für die Brechstangenaktion von der API?

mit MyThread.Terminate läuft er ja noch theoretisch wenn ein sleep im thread eingebaut ist.

MyThread. ????
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 01.05.05 14:38 
Siehe letztes Wort in Sprint's Post ^^

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: So 01.05.05 14:51 
Also mit MyThread.TerminateThread; sagt er mir ungültigerbezeichner.

Glaub bei mir handelt es sich nur um ein grammatik problem.

Wie soll ich das schreiben?
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: So 01.05.05 15:07 
TerminateThread(threadid,0)

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit