[fpc-pascal] Re: Library callback : how do I do that?
Lukasz Sokol
el.es.cr at gmail.com
Thu Aug 8 13:55:47 CEST 2013
On 08/08/13 12:50, Henry Vermaak wrote:
> On Thu, Aug 08, 2013 at 12:15:44PM +0100, Lukasz Sokol wrote:
>> but I would then need to make the wrapper object aware of the Application
>> or its forms then?
>>
>> I wanted the wrapper unit to be as self-contained as much as possible,
>> (so the callback function is defined in a unit that only has Classes, SysUtils and dynlibs as uses,
>> i.e. no Forms. Controls or Graphics)
>> but still be thread-safe w/r/t to where the wrapper object is created
>> (within a GUI form or /not/)
>
> Create an event in your wrapper class and make sure that it's documented
> that this event will be called from a thread. Then if you use this
> wrapper class from a gui app, you can use Application.QueueAsyncCall or
> PostMessage in the event handler. If you use the wrapper from a command
> line app, you'll have to use a thread-safe queue that you query from
> time to time in the main thread of the app, or build it into your event
> loop, if you have one.
>
> Henry
Thanks - I see it's the only way forward then :)
Lukasz
More information about the fpc-pascal
mailing list