Doing multi-threading jobs inside AutoCAD .Net plugin

Doing multi-threading jobs inside AutoCAD .Net plugin

Anonymous
Not applicable
1,564 Views
1 Reply
Message 1 of 2

Doing multi-threading jobs inside AutoCAD .Net plugin

Anonymous
Not applicable

I am aware that Autocad APIs are not supposed to be called/used in multi-threading. But how about doing a multi-thread job(in an Autocad .Net plugin) that does not involve any specific Autocad calls/type?

The situation is like this:
1.some CAD polylines are fetched through APIs, their properties that are of interest are wrapped in custome types and then
2.In another layer some multi-thread calculations are done against these custome types.
3.The application custome types writing their results back to the CAD polylines through Autocad APIs.


Only step two is done in multi-threads.

The application uses StartTransaction() method to get the Transaction object. I haven't experienced any crashing so far for many years. But now I am trying to use StratOpenCloseTransasction() it crashes many times. Specially it crashes when Editor.Rengen() is called as I think it goes through every object in database and perhaps some are corrupted. I did narrow down the problem and one of the causes apparently is this multi-threading.


Is there any reason that CAD should crashes in calling multi-threads although no APIs is engaged? Am I safe to use multi-threading in this way?
Does StartTransaction() handles objects better than StartOpenCloseTransaction in terms of disposing them? As I didn't experience crashing on that.

Many thanks,
Ali

0 Likes
1,565 Views
1 Reply
Reply (1)
Message 2 of 2

_gile
Consultant
Consultant

Hi,

 

You can do some multi thread job in an AutoCAD plug-in, even with some AutoCAD non database resident objects as those of the Geometry namespace.

 

In this example, a parallel task is used to build a Point3dTree (kd tree of AutoCAD Point3d instances).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes