On Thu, Aug 08, 2013 at 11:34:53AM +0100, Lukasz Sokol wrote: > This would be fine, IFF i was adding this to the main form of my > application... but I'm not. I'm trying to wrap this .dll in a > separate unit, only communicating to the form through a wrapper > object, defined in a separate unit. The object itself, would be > created /by/ the form window, but won't be a GUI object, so won't be > in the message queue; > > Doing a chain like: > > (Setup) (form passes its handle to the object) -> (object installs > callback function) and then (normal operation) (form receives callback > via Windows Message) -> (form calls e.g OnCallback function of the > object) > > seems a bit backwards. > > I can imagine, that I need to have the Callback procedure as > > procedure Callback(Port, Event, Value : Integer); stdcall; > > but how do I call functions/procedures of MyObject in a threadsafe > manner from there?
Lazarus has QueueAsyncCall, which is a thread safe, cross platform way of queueing method calls asynchronously. E.g. for USB hotplug notification, I register this function with my device library: procedure NotifyPlug(status: cint); cdecl; begin Application.QueueAsyncCall(@MainForm.NotifyAsync, status); end; Henry _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal