How to make `CALLBACK` function across threads?

It seems when I set up a callback in Global Embeds > Program Setup the callback only triggers for the main thread, when a window is opened with START the callback won’t trigger in that thread unless I add another call to CALLBACK - is there a way to set the callback once and have it run regardless the thread it’s on?

Is the DCT file set to threaded?

ABFile.inc

FileManager                   CLASS,IMPLEMENTS(FileCallBackInterface),TYPE,MODULE('ABFILE.CLW'),LINK('ABFILE.CLW',_ABCLinkMode_),DLL(_ABCDllMode_)

FileCB.inc

FileCallBackInterface INTERFACE
FunctionCalled PROCEDURE(SIGNED opCode, *Params Parameters, *CSTRING FileErrCode, *CSTRING FileErrMsg), BYTE
FunctionDone   PROCEDURE(SIGNED opCode, *Params Parameters, *CSTRING FileErrCode, *CSTRING FileErrMsg), BYTE
                      END

I don’t know anything about that thing you’re using, but if you are using a class, you could IMPLEMENT Capesoft GUTS Interface. Then you can communicate to any other objects that also implement the GUTS interface. May or may not be what you’re looking for, but it is free, thread independent, and relatively easy to use once it’s set up.

Check out the stuff about “Family”. I think that’s what you need. CapeSoft GUTS Complete Documentation

https://www.capesoft.com/accessories/gutssp.htm

The application is still Legacy Clarion, so no ABC - but File does not have the THREAD attribute - it’s a TOPSPEED file if that matters

Did it by creating a *Manager class, which has the THREAD attribute and in it’s CONSTRUCT sets the callbacks (DESTRUCT removes them) - this way, on each thread a new instance is created and the callbacks are added again.

Borrowed the idea from: Thread termination monitoring / was: Passing procedure as a parameter prior to 11.1 - #4 by MarkGoldberg

It makes sense to me that the CallBack(File) monitoring must be “enabled” for each Thread .. when the File is THREAD. Having it always get posts from every Thread that opens and handle them seems it could be difficult.

It you look at the ABC FileManager Class it the Implements(FileCallBackInterface). If the File is THREAD then the Class is THREAD so the CallBack is a new instance limited to one Thread. For a Non-Thread file there is one Non-Thread FM so it must get call backs from all Threads

If you have any Non-Thread files you should check how it works. You would Not want it removed in the Destruct.