Skip to main content

mathlink or wstp - Can you trigger update of Dynamic elements from a LinkedLibrary?


Is it possible to write a LinkedLibrary (or WSTP executable) computing a function f such that


Dynamic@f[]

is updated when the library deems it necessary?



I think it should be possible if the library has a background thread and can somehow change a global symbol within the Mathematica session.


Has anyone ever done this?




Context: I want to replicate


CurrentImage[] // Dynamic

with the output of a simulation or the data read from some unsupported device or something.


Also, I would like to have a variable $file that always reflects the contents of a text file file.txt, even after I change that in an external editor. I know how to listen for changes to a file with the Windows API, so I could do it in C and forward the changes when necessary.




Comments