Line | |
---|
1 | unit UMainForm;
|
---|
2 |
|
---|
3 | {$mode objfpc}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | UExceptionLogger;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TSampleThread }
|
---|
14 |
|
---|
15 | TSampleThread = class(TThread)
|
---|
16 | procedure Execute; override;
|
---|
17 | end;
|
---|
18 |
|
---|
19 | { TMainForm }
|
---|
20 |
|
---|
21 | TMainForm = class(TForm)
|
---|
22 | Button1: TButton;
|
---|
23 | Button2: TButton;
|
---|
24 | ExceptionLogger1: TExceptionLogger;
|
---|
25 | procedure Button1Click(Sender: TObject);
|
---|
26 | procedure Button2Click(Sender: TObject);
|
---|
27 | private
|
---|
28 | { private declarations }
|
---|
29 | public
|
---|
30 | Thread: TSampleThread;
|
---|
31 | end;
|
---|
32 |
|
---|
33 | var
|
---|
34 | MainForm: TMainForm;
|
---|
35 |
|
---|
36 | implementation
|
---|
37 |
|
---|
38 | { TSampleThread }
|
---|
39 |
|
---|
40 | procedure TSampleThread.Execute;
|
---|
41 | begin
|
---|
42 | try
|
---|
43 | raise Exception.Create('Exception inside thread');
|
---|
44 |
|
---|
45 | except
|
---|
46 | on E: Exception do
|
---|
47 | MainForm.ExceptionLogger1.ExceptionHandler(Self, E);
|
---|
48 | end;
|
---|
49 | end;
|
---|
50 |
|
---|
51 | {$R *.lfm}
|
---|
52 |
|
---|
53 | { TMainForm }
|
---|
54 |
|
---|
55 | procedure TMainForm.Button1Click(Sender: TObject);
|
---|
56 | begin
|
---|
57 | raise Exception.Create('Simple exception');
|
---|
58 | end;
|
---|
59 |
|
---|
60 | procedure TMainForm.Button2Click(Sender: TObject);
|
---|
61 | begin
|
---|
62 | Thread := TSampleThread.Create(True);
|
---|
63 | Thread.FreeOnTerminate := True;
|
---|
64 | Thread.Start;
|
---|
65 | end;
|
---|
66 |
|
---|
67 | end.
|
---|
68 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.