source: ExceptionLogger/Demo/UMainForm.pas

Last change on this file was 281, checked in by george, 13 years ago
File size: 1.1 KB
Line 
1unit UMainForm;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 UExceptionLogger;
10
11type
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
33var
34 MainForm: TMainForm;
35
36implementation
37
38{ TSampleThread }
39
40procedure TSampleThread.Execute;
41begin
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;
49end;
50
51{$R *.lfm}
52
53{ TMainForm }
54
55procedure TMainForm.Button1Click(Sender: TObject);
56begin
57 raise Exception.Create('Simple exception');
58end;
59
60procedure TMainForm.Button2Click(Sender: TObject);
61begin
62 Thread := TSampleThread.Create(True);
63 Thread.FreeOnTerminate := True;
64 Thread.Start;
65end;
66
67end.
68
Note: See TracBrowser for help on using the repository browser.