Search code examples
c#multithreadingmatlabmatlab-deployment

Matlab compiled to. NET - what about thread safety?


If I to call matlab function compiled by Builder NE in multi-threaded near real-time application, how should. I approach thread safety issue? Shall I create single instance of matlab object and serialize access in c# or shall I instantiate one object for each thread?


Solution

  • I would suggest using a single instance, the MCR will serialize access for you. One object per thread might be too much overhead.

    http://www.mathworks.com/support/solutions/en/data/1-ELVN0M/index.html?product=CO&solution=1-ELVN0M

    *Note - MCR is the MATLAB runtime, you could think of it as a scaled down MATLAB session running in the backgroun.