I wrote a simple matlab filewatcher object than uses .NET's FileSystemWatcher. It's a great little tool, works straight off the bat and you can add a Matlab callback directly. So far so good.
This worked perfectly in R2015a. I compile this in a larger stand-along application that my colleagues use and the .exe application works perfectly.
Enter R2015b (and R2016a): Works fine when running natively in Matlab but when run as a compiled .exe (even on my own machine) it crashes whenever the callback for the file watcher is asked to execute.
The reason for this is apparently that the callback tries to execute on a different thread and this crashes the application. This has been reported as bug 560506. It's been around for a long time (since R2009a) yet this doesn't happen in R2015a. In the bug report it says the workaround is to not invoke the callback MATLAB code delegate in a separate thread. Does anybody know how to do that?
I realise I could implement this in java but that requires java dev, it requires dragging a jar file along and requires "indirect" callback attachment. I also realize I could stay with R2015a but recently I have developed code with findgroups that obviously does not exist in R2015a.
So if anyone can point me in the right direction for forcing the callback execution on the main/single thread that would be absolutely great.