Thread termination monitoring / was: Passing procedure as a parameter prior to 11.1


is there any easy trick to pass a reference to a procedure as a parameter to another procedure in Clarion versions prior to 11.1?

I know the workaround with declaring a procedure with the same signature, but as external (like for dynamic loading), which will be like a delegate, and then passing its address through a variable with a name attribute like the label of the delegate.
Unfortunately, due to the need to use this for around 1000 procedures, this solution is not acceptable in this case.


Are the procedure prototypes suitable for being called by EVALUATE? Or are they similar enough to just pass the name to a procedure, which then calls the procedure directly?

Hi Jeff, no, unfortunately they are not.

Or maybe there is some undocumented callback (prop:lib, xxx) that RTL calls at the end of a thread? Because this is actually the clue of our problem. We need to know when the thread closes. The first idea was to add a wrapper procedure that would always be called when START was called.



Clarion ThreadMonitor class - used to Notify a thread as each thread starts and ends (

   INCLUDE(''),ONCE    !<-- threaded instance
ThreadMonitor ctThreadMonitor,THREAD 

   ThreadMonitor.ConstructEvent( 0 ) !<-- disable
   ThreadMonitor.DestructEvent (Event:ThreadEnded)
   ThreadMonitor.ThreadToInform( AppFrame{prop:Thread} )

   ! where Event:ThreadEnded is an Event:App+N
1 Like

Unfortunately this seems to require adding code in every procedure that is started in a new thread, but still it is the best option we have at the moment. Many thanks, Mark!

EDIT: I was wrong. We can declare the object globally and the instance will be created and destroyed automatically for each thread. It is great :smiley:

1 Like