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
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
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.
You can also read this post on the subject: http://adndevblog.typepad.com/autocad/2012/06/use-thread-for-background-processing.html