[Lazarus] Mutlithreaded Dll Callback crashes my Application

Sven Barth pascaldragon at googlemail.com
Thu Aug 26 09:39:23 CEST 2010


Am 26.08.2010 08:18, schrieb Maik Wojcieszak:
> initialization
> // Set pascal specific thread creators
> vortex_thread_set_create(@fpc_vortex_thread_create);
> vortex_thread_set_destroy(@fpc_vortex_thread_destroy);
> ...
>
>
> The question is now: Why does this work ?
>
> If BeginThread initializes the stack which needs to be done to make
> external threads work it will work with this example
> too. Did the creator of this code find a regular solution for this
> problem or did he just work around the problem by making
> external threads internal ?

I took a quick look at the vortex library.

The "magic" happens in those two functions that are passed in the 
initialization section. Those tell the vortex library to not use it's 
own threading creation and destruction methods, but to let the calling 
application (in this case the FPC one) create the threads. That was a 
rather intelligent approach by the developers of the vortex library as 
it allows threading systems that need special initialisation (like ours) 
to be used.

Effectively those calls start a "FPC internal" thread and is the best 
way to circumvent external thread problems.

Regards,
Sven




More information about the Lazarus mailing list