Thema: Delphi Realtime Input? Thread?

Einzelnen Beitrag anzeigen

Benutzerbild von DGL-luke
DGL-luke

Registriert seit: 1. Apr 2005
Ort: Bad Tölz
4.149 Beiträge
 
Delphi 2006 Professional
 
#17

Re: Realtime Input? Thread?

  Alt 14. Mai 2006, 13:51
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
  Mit Zitat antworten Zitat