Did anyone have experince with document manager API in multithread environment ?

Hi everyone,

I'm working on C++ addin for Solidworks 2015. I'm using document manager in a worker thread for modify some document features. Untill now I haven't any big problem, but I would to know if someone have some related experience for sharing.

Thank you in advance.

Regards,

Simone

SolidworksApi macros
Answers 4
RJ
RJ 2016-02-19 Best Answer

Hi Simone,

PDM system development involves using Document Manager APIs in a multi-threaded environment. Your description appears similar.

I have done development for PDM systems involving multi-threaded environment and I have never found any issue. If you face some problem then feel free to share.

Hope it helps!!!

Rajat Jain

SP
SP 2016-02-19

Hi Jain,

thank you for the answer. Provided that I'm using the Microsoft concurrency library to manage task, the first question could be: Could it be rigth initialize two or more task (simplyifing two or more thread) with CoInitialize(nullptr) (single thread), in which every task use an instance of Document manager COM object, but no one share any data ?

Explaining by example:

// Main thread

{

         ...

     structured_task_group group;

    auto task1(concurrency::make_task([]

     {

           // This task potentially run in separated thread

           ::CoInitialize(nullprt); // Single thread

          // Use document manager library

          ...

     });

     auto task2(concurrency::make_task([]

     {

           // This task potentially run in another separated thread

           ::CoInitialize(nullprt); // Single thread

          // Use document manager library

          ...

     });

     group.run(task1);

     group.run(task2);

     group.wait();

     ...

}

Thank you.

Simone

RJ
RJ 2016-02-19

Hi Simone,

I do not think there should be any issue with this concept. I just did the following to test this case: -

I ran 2 different versions of SolidWorks (2012 and 2015) on my machine simultaneously. Both the versions loaded correctly. They both loaded the same addin (which uses Document Manager API) correctly. The 2 versions are running on different threads.

Hope it helps!!!

Rajat Jain

SP
SP 2016-02-20

Hi Jain,

good new. If I will have any problems, I'll send a replay in this discussion.

Thank you again.

Regards,

Simone