From: John Reilly on 28 Jan 2010 14:38 Hi Satish, COM objects live in something called apartments, which are loosely related to threads. The MATLAB COM object is probably single threaded, which means it should only be used in the thread in which the object was created. If you call it from another thread, it may work, and it may not. It may work for some time, and then fail. If it is a single threaded COM object, then you must create the COM objects in thread with Windows message pumps. If not, they tend to not work because the COM engine uses the message pump for "things." I don't have any code to help you, but perhaps you can go to www.codeProject.com and see if there is an article about creating background / worker threads with message pumps in C#. Good luck. -reilly. "Satish T" <tsatish1304(a)gmail.com> wrote in message <heros5$iq$1(a)fred.mathworks.com>... > Hi, > I am using C# with Matlab Automation Server Type Library. > I have a global variable in the class holding the instance to the MLAppClass.. > > In the process, I invoke a seperate thread for running a time consuming task involving matlab. In that task I loop over several number of times and every time, i push some data into matlab, execute some commands, retrieve back the outputs generated. > (Note that the MLAPClass global variable is created by the main thread). > After 160 iterations, the MLAppClass started behaving weirdly. It can no more execute commands in matlab. Viewing the variable in Watch/Quick watch displays function evaluation timed out and nothing happens from there. > I have created a new mlappclass variable in Secondary thread but no luck. > > I see com objects experience some problems in accessing over multiple threads. > Can anyone help me out in fixing this issue? is there any other procedure that need to be followed when accessing the MLAPPClass over multiple threads? > > Code snippets would be very much helpful. > > Thanks, > Satish
|
Pages: 1 Prev: how to locate a string in a string cell? Next: mex - Matlab array errors |