Hi,
> For starters - are you 100% positive there is no contention with
> variables shared by the threads? Perhaps unknowningly? Are you sure the
> entire lineage of code you are calling in Synapse and in FreePascal's
> supplied units (FCL/RTL) and lazarus components are NOT stomping each
> other?
>
Yes, I simplified the project so much, that the error must be eitherin
synapse or the fpc tthread. (I also use logging system like you
suggested, but I added so many additional layers over synapse that the
output isn't clear in the full project)
Nevertheless, this is the test file: (not exactly the same source as in
the project because I use THttpSend instead of HttpGetText in the
project, but the error is the same)
[...]
type
{ ttestthread }
ttestthread=class(Tthread)
result:string;
procedure execute;override;
end;
var
Form1: TForm1;
gurl:string;
implementation
function getUrl():string;
var
temp: TStringList;
begin
temp:=TStringList.create;
try
HttpGetText(gurl,temp);
if temp.Count<1 then result:='empty:'+IntToStr(temp.Count)
else result:='got:'+temp[0]+temp[1];
finally
temp.free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.lines.add(geturl);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
test: ttestthread;
begin
test:=ttestthread.Create(true);
test.Result:='wtf';
test.OnTerminate:=...@testterminate;
test.Resume;
end;
procedure TForm1.Button6Click(Sender: TObject);
var
i: Integer;
begin
for i:=1 to 10 do button1Click(self);
end;
procedure TForm1.testTerminate(Sender: TObject);
begin
if (sender is ttestthread) then
memo1.lines.add(ttestthread(sender).result);
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
gurl:=edit1.text;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1Change(self);
end;
It normally fails directly after I started the program or changed the
url and then clicked on Button6.
And the threads don't crash, only some of them report an empty download.
(and when I click a second time on the button it often works, until I
clicked too often)
Benito van der Zander
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public