source8 PFXI7XYCBIPPXQZZEAU53OMRHCV7SGDK7N4TLZQ








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:
source30
Matrix3?pp source
Thread?pp source
arm biquad ?scade ?1 ?st q31? source
arm conv ?2? source
arm mat mult q15? source
Resource 8inl source
arm fir lattice init q31? source
arm fir ?cimate ?st q15? source
source11
arm correlate ?st q15? source
connector?s source
register? source
passing values source
arm iir lattice init ?2? source
arm mult q31? source
2004 11 Porównanie serwerów relacyjnych baz danych Open Source [Bazy Danych]

więcej podobnych podstron