Accessing AutoCAD's COM api from .Net framework

Accessing AutoCAD's COM api from .Net framework

TK_Rao5AR2
Participant Participant
292 Views
2 Replies
Message 1 of 3

Accessing AutoCAD's COM api from .Net framework

TK_Rao5AR2
Participant
Participant

Accessing AutoCAD's COM api from out-of-process is not a challenge (I am using .Net framework 4.8). However when I react to events such as ObjectAdded, ObjectModified etc., they are executed in a worker thread.

There is a need to keep these events on the Main thread. Any ideas on how to achieve this?

 

Thanks,

TK

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

ActivistInvestor
Mentor
Mentor

I don't think there's any option for configuring what thread the events are raised on, as that's determined by the server. 

 

You can deal with it using Control.Invoke() or SynchronizationContext.Post().

 

I would also point out that events like those you cite can fire at a very high frequency, and when handling them from an out-of-process client, there will be significant overhead imposed on the end user. Given the other options for AutoCAD development, handling high-frequency events in an out-of-process client is not something I would recommend.

0 Likes
Message 3 of 3

TK_Rao5AR2
Participant
Participant

Thank you. I ended up using SynchronizationContext.Post().

 

There is no choice but to use it out-of-process as another application is launching and controlling autocad. That other application works well when AutoCAD is on the Main Thread. Its a requirement.

 

-TK

0 Likes