-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulatorthreads.pas
More file actions
54 lines (39 loc) · 847 Bytes
/
simulatorthreads.pas
File metadata and controls
54 lines (39 loc) · 847 Bytes
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
unit SimulatorThreads;
{$mode ObjFPC}{$H+}
interface
uses
{$ifdef unix}cthreads,{$endif} Crt, Graphics, ExtCtrls,
ProgramCode;
var
Image1: TImage;
OffscreenImage: TBitmap;
finished: Boolean;
procedure startThreads;
implementation
function RepaintLoop(p : pointer) : ptrint;
begin
Writeln('repaint thread started');
while not finished do
begin
Delay(330); // three times per second
Image1.Invalidate;
end;
Writeln('repaint thread finished');
RepaintLoop := 0;
end;
function Code(p : pointer) : ptrint;
begin
Delay(1000);
Writeln('program code thread started');
ProgramCode.Run;
Writeln('program code thread finished');
Delay(1000);
finished := True;
Code := 0;
end;
procedure startThreads;
begin
BeginThread(@RepaintLoop, pointer(1));
BeginThread(@Code, pointer(2));
end;
end.