Entiy usage in separate thread.

Entiy usage in separate thread.

Anonymous
Not applicable
705 Views
2 Replies
Message 1 of 3

Entiy usage in separate thread.

Anonymous
Not applicable

Hello

 

Recently I faced with the following problem:

I want user to select some Entities and than perform with them some calculations. But calculations are time consuming and I decided to move them to separate thread. But when calculations are performed in background thread AutoCAD UI is available and user can edit/remove any of selected Entities.

 

The question: Is it possible to

1) Forbid user to edit drawing while calculation is performed, or . . .

2) Make drawing-independent copies of Entities, or . . . 

3) Continue calculations even if drawing was closed?

 

 

I've already tried MdiActiveDocument.DocumentLock()

and

Entity.Clone() and tackle about Entity.DeepClone() but still didn't find a solution.

 

Thanks for attention.

 

 

0 Likes
706 Views
2 Replies
Replies (2)
Message 2 of 3

chiefbraincloud
Collaborator
Collaborator

To my knowledge, you can not use the managed API from a separate thread (I think even if you are using COM, the calls to the AutoCAD COM interface would still execute under AutoCAD's thread).  It is for that reason that I have not played around with threading very much.

 

If I am mis-interpreting what you are trying to do, and you know for a fact that your separate thread will work, then I am pretty sure there is a mechanism for managing the thread and waiting for it to complete before returning, which would keep the ACAD UI unavailable to the user.

Dave O.                                                                  Sig-Logos32.png
0 Likes
Message 3 of 3

Anonymous
Not applicable

But I've did a lot of work, to move all calculations to a separate thread. Now I have 3 threads: 1) Acad main GUI thread 2) Calculation GUI thread 3) Calculation thread

 

During my calculations I don't need entire Entity, just its boundary representation and I do only Read operations. May be there is sense to create some drawing-independent wrappers around Entity and Brep?

0 Likes