Hi Mark,
I’ve attached an example experiment (scheduled_task.xml) that demonstrates MWorks’ “scheduled actions” feature. It’s roughly based on the scenario you described (i.e. scheduling a background thread that sends TTL pulses at regular intervals, and synchronizing to those pulses in your experiment).
The basic idea of the experiment is to set up a scheduled-actions component that sends a pulse (i.e. sets a variable to 1) 10 times, with a one-second delay between each pulse. Once the scheduled actions are started, the experiment uses a conditional state transition to wait for and record each pulse. Once all 10 pulses have been received, the experiment ends.
One limitation of this approach is that you have to know up front how many times you want the scheduled actions to run. An alternative approach would be to set the number of repetitions really large (so that the actions effectively repeat forever) and use a “cancel_scheduled_action” action to stop them. Unfortunately, there’s a bug that prevents this from working, so for the moment you’re stuck with using a fix number of repetitions.
In any case, scheduled actions should give you an alternative to spawning a background thread from your plugin code.
Cheers,
Chris