Delphi-Quellcode:
TTest =
class
private
TestString :
string;
public
constructor create;
procedure DoSomething;
procedure ShowString;
end;
var
Form1 : TForm1;
test : TTest;
implementation
{$R *.dfm}
constructor TTest.create;
begin
inherited;
TestString := '
Hallo';
end;
procedure TTest.DoSomething;
begin
while true
do
begin
Application.ProcessMessages;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
test := TTest.create;
test.DoSomething;
test.free;
end;
procedure TTest.ShowString;
begin
ShowMessage(TestString);
// Exception: EAccessViolation
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
test.ShowString;
end;
In deine alten wurde die Instance noch nihct freigegeben so schon.
Schon mal was von TThread's gehört?