ah... think i got you.
You have to place the thing you want to be able to suspend in the second thread.
well, your first example does work fine with me:
Delphi-Quellcode:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 =
class(TForm)
{...}
end;
TFiber=class(TTHread)
procedure execute;
override;
end;
var
Form2: TForm2;
Fiber: TFiber;
implementation
procedure TFiber.execute;
var i:integer;
begin
i := 0;
repeat
ShowMessage(IntToStr(i));
Suspend;
i:=i+1;
until i=3;
end;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
Fiber.Resume;
end;
procedure TForm2.FormShow(Sender: TObject);
begin
Fiber := TFiber.Create(false);
end;
end.
@C.Schoch: Yes, if you want to stop the thread like when the user says so or similarly.
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1