Error on Responsive Apps Delphi XE7 using Thread Unidac and TAsyncImageLoader
Posted: Thu 20 Nov 2014 13:12
I want to create responsive apps using delphi xe7 which fetch mysql database from server and display in device without lagging.
below is simple example code which i wrote to display image from server which is image path fetched from my mysql database.
FYI Im using Unidac connection and for image loader im using this one http://www.fmxexpress.com/threaded-prog ... d-and-ios/.
The problem occurs when i run this procedure for the second time call.
First time call this procedure, everything runs as expected without any error, but when I run this procedure for second time, I got so many errors for example:
"Segmentation Fault",
"EIdConnClosedGracefully with msg Connection Closed Gracefully",
"EIdReadTimeout", until
"Access Violation"
What makes this problem occurs and how to solve it?
Desperately need help on this

below is simple example code which i wrote to display image from server which is image path fetched from my mysql database.
FYI Im using Unidac connection and for image loader im using this one http://www.fmxexpress.com/threaded-prog ... d-and-ios/.
Code: Select all
procedure TForm1.GetUserPhoto;
begin
TThread.CreateAnonymousThread(procedure ()
var
queryresult:Tstringlist;
begin
queryresult:=TStringList.Create();
RemoteConnQuery.SQL.Text:='<MYSQL QUERY STATEMENT>';
RemoteConnQuery.Open;
while not RemoteConnQuery.Eof do
begin
queryresult.add(RemoteConnQuery.FieldByName('userimagefilepath').AsString);
RemoteConnQuery.Next;
end;
TThread.Synchronize (TThread.CurrentThread,
procedure ()
var
ctr: Integer;
profileAsyncImage:array of TAsyncImageLoader;
begin
for ctr := 0 to queryresult.Count-1 do
begin
SetLength(profileAsyncImage,ctr+1);
profileAsyncImage[ctr]:=TAsyncImageLoader.Create(nil);
profileAsyncImage[ctr].Parent:=layout1;
profileAsyncImage[ctr].Width:=40;
profileAsyncImage[ctr].Height:=40;
profileAsyncImage[ctr].Pooled:=true;
profileAsyncImage[ctr].Image.WrapMode:=TImageWrapMode.Stretch;
profileAsyncImage[ctr].GetURL('http://www.domain.com/'+queryresult[ctr]+'.png');
profileAsyncImage[ctr].Position.X:=10;
profileAsyncImage[ctr].Position.Y:=ctr*100;
end;
end);
end).Start;
end;
First time call this procedure, everything runs as expected without any error, but when I run this procedure for second time, I got so many errors for example:
"Segmentation Fault",
"EIdConnClosedGracefully with msg Connection Closed Gracefully",
"EIdReadTimeout", until
"Access Violation"
What makes this problem occurs and how to solve it?
Desperately need help on this