Source8
unit PrimeForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TPrimeFrm = class(TForm)
NumEdit: TEdit;
SpawnButton: TButton;
ResultsMemo: TMemo;
procedure SpawnButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
FThreadRefCount: integer;
procedure HandleTerminate(Sender: TObject);
public
{ Public declarations }
end;
var
PrimeFrm: TPrimeFrm;
implementation
uses PrimeThread;
{$R *.DFM}
procedure TPrimeFrm.SpawnButtonClick(Sender: TObject);
var
NewThread: TPrimeThrd;
begin
NewThread := TPrimeThrd.Create(True);
NewThread.FreeOnTerminate := True;
try
with NewThread do
begin
TestNumber := StrToInt(NumEdit.Text);
Inc(FThreadRefCount);
OnTerminate := HandleTerminate;
Resume;
end;
except on EConvertError do
begin
NewThread.Free;
ShowMessage('That is not a valid number!');
end;
end;
end;
procedure TPrimeFrm.FormCreate(Sender: TObject);
begin
FThreadRefCount := 0;
end;
procedure TPrimeFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := true;
if FThreadRefCount > 0 then
begin
if MessageDlg('Threads active. Do you still want to quit?',
mtWarning, [mbYes, mbNo], 0) = mrNo then
CanClose := false;
end;
end;
procedure TPrimeFrm.HandleTerminate(Sender: TObject);
begin
Dec(FThreadRefCount);
end;
end.
Wyszukiwarka
Podobne podstrony:
source30Matrix3?pp sourceThread?pp sourcearm biquad ?scade ?1 ?st q31? sourcearm conv ?2? sourcearm mat mult q15? sourceResource 8inl sourcearm fir lattice init q31? sourcearm fir ?cimate ?st q15? sourcesource11arm correlate ?st q15? sourceconnector?s sourceregister? sourcepassing values sourcearm iir lattice init ?2? sourcearm mult q31? source2004 11 Porównanie serwerów relacyjnych baz danych Open Source [Bazy Danych]więcej podobnych podstron