[Lazarus] Mutlithreaded Dll Callback crashes my Application
José Mejuto
joshyfun at gmail.com
Wed Aug 25 20:08:38 CEST 2010
Hello Lazarus-List,
Wednesday, August 25, 2010, 8:44:53 AM, you wrote:
MW> I've packed the runtime env dlls and put them on my ftp server.
MW> They are too big to attach to the mail on the list.
Do you have compiled the "vcmtdll.dll" with Multithread runtime
library (/MT) ?
To avoid crashes just simply:
// start threads
for index := 0 to FThreads.Count-1 do
begin
TVCMTThread(FThreads.Items[index]).Start(10);
Sleep(50);
end;
Adding the Sleep(50) avoids any crash, and the AsyncWrite works as
expected. You should also add a Sleep(50) after each FThreads[n].free
If a multithread problem is solved with sleeps usually it is a race
condition in the RTL, in this case you create a new thread while the
provious one is being created (or destroyed), so to me looks like a
VC++ non multithread RTL problem.
It is also desirable to add the line "IsMultithread:=true" in the
first line of .lpr (after the begin) to activate the Multithread RTL
in the FPC, otherwise it could not be active.
I had tested it with 200 threads and using the sleeps no problem at
all.
--
Best regards,
José
More information about the Lazarus
mailing list