-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUnit1.pas
More file actions
92 lines (67 loc) · 1.87 KB
/
Unit1.pas
File metadata and controls
92 lines (67 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.ScrollBox, FMX.Memo, FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm6 = class(TForm)
Button1: TButton;
Memo1: TMemo;
AniIndicator1: TAniIndicator;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Déclarations privées }
FMyThread1IsStart : boolean ;
public
{ Déclarations publiques }
end;
var
Form6: TForm6;
implementation
{$R *.fmx}
procedure TForm6.Button1Click(Sender: TObject);
begin
Memo1.Lines.Clear ;
FMyThread1IsStart := True ;
Memo1.Visible := False ;
// Démarrer le Thread Anonyme
TThread.CreateAnonymousThread(
procedure()
var
I: Integer;
begin
for I := 0 to 10000 do begin
Memo1.Lines.Add('lines : ' + I.ToString) ;
//Synchrnisation avec l'application principale pour pouvoir stopper le Thread Anonyme
TThread.Synchronize(TThread.CurrentThread,
procedure()
begin
if FMyThread1IsStart = False then begin
Memo1.Visible := True ;
Memo1.Lines.Add('Thread Arrèté') ;
TThread.Current.Terminate ;
end;
end);
end;
//Synchrnisation avec l'application principale pour signaler la fin du Thread Anonyme
TThread.Synchronize(TThread.CurrentThread,
procedure()
begin
Memo1.Lines.Add('Thread Fini') ;
Memo1.Visible := True ;
end);
end).Start;
end;
procedure TForm6.Button2Click(Sender: TObject);
begin
FMyThread1IsStart := False ;
end;
procedure TForm6.FormShow(Sender: TObject);
begin
FMyThread1IsStart := False ;
end;
end.