-
Notifications
You must be signed in to change notification settings - Fork 0
/
testootack.pas
60 lines (52 loc) · 1.18 KB
/
testootack.pas
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
uses SysUtils,ObjectModel;
type
tSampleTask=object (tTask)
protected
procedure Abort;virtual;
public
procedure Test69;
end;
type t=object
procedure H( task:tTask_ptr; event:tTaskEvent; data:pointer );
procedure W( task:tTask_ptr; event:tTaskEvent; data:pointer );
end;
procedure tSampleTask.Abort;
begin
writeln('task abandoned');
end;
procedure tSampleTask.Test69;
begin
self.SendEvent(tevComplete,nil);
end;
var o:t;
var t1,t2:tSampleTask;
procedure t.H( task:tTask_ptr; event:tTaskEvent; data:pointer );
begin
write('H Event ',event,' from ');
if task=@t1 then writeln('t1');
if task=@t2 then writeln('t2');
task^.Detach(@h);
end;
procedure t.W( task:tTask_ptr; event:tTaskEvent; data:pointer );
begin
write('W Event ',event,' from ');
if task=@t1 then writeln('t1');
if task=@t2 then writeln('t2');
//if event<>tevClose then task^.Detach(@w);
end;
BEGIN
t1.Init;
t2.Init;
writeln('attach t1 to @h.O');
t1.Attach(@o.H);
t1.AttachWeak(@o.W);
writeln('attach t2 to @h.O');
t2.AttachWeak(@o.W);
t2.Attach(@o.H);
writeln;
writeln('test69 on t1');
t1.Test69;
writeln;
writeln('detach t2');
t2.Detach(@o.H);
end.