.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Launch command mode asynchronou​s

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
339 Views, 3 Replies

Launch command mode asynchronou​s

 

Hello,

 

I'm in autocad.net and I would like to run a command that I have developed.

This command takes several minutes and I want to go back to AutoCAD before this command ends.

 

How can I do it?

Thanks,

 

Ane

3 REPLIES 3
Message 2 of 4
norman.yuan
in reply to: Anonymous

AutoCAD does not support multi-threads when working with drawing (Document/Database). So, depending on what your command does, you may or may not run it in background thread.

 

If your command is to do the usual AutoCAD stuff, such as accessing drawing to manipulate something in the drawing, then, you cannot do it in a separate thread. You can only run synchronously, however long it takes AutoCAD to work it out.

 

If your command is to do something not related to AutoCAD itself, such as going out to the net to access a service for some information, which may take long time, then, you can start a backgroud thread to do that. However, you must be very careful when the background thread is done and is to return to AutoCAD (unless it is one way call to external services): direcct returning to AutoCAD when the side thread is done is dangerous: AutoCAD is very like in a middle of a command/process.

 

I have an article posted here on this topic, which describe a way to start a side thread to do something unrelated to AutoCAD/drawing process, some kind of one way call out:

 

HTH

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4
dgorsman
in reply to: Anonymous

Might be time to re-evaluate the program logic to optimize for speed.  Look for opportunities to take early exits from loops, remove procedures from loops that only need to be done once, cache frequently used data from external files in memory, and so on.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 4 of 4
FRFR1426
in reply to: norman.yuan

You can also read this post on the subject: http://adndevblog.typepad.com/autocad/2012/06/use-thread-for-background-processing.html

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Tags (1)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost