Invoke command or function from other thread

Invoke command or function from other thread

Anonymous
Not applicable
2,349 Views
5 Replies
Message 1 of 6

Invoke command or function from other thread

Anonymous
Not applicable

I know that ObjectARX API not available from other threads except AutoCAD thread. But maybe I can invoke command or function from other thread to run command in AutoCAD thread?

And what is Application.Invoke() method? I can't find info about this method.

 

Thanks.

0 Likes
Accepted solutions (2)
2,350 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Accepted solution

You can try calling the ActiveX SendCommand() method from the

other thread, and use it to invoke a CommandMethod you define,

that can do the work in the AutoCAD thread.

 

The Invoke() method invokes LISP functions, but only works from the

document context.

0 Likes
Message 3 of 6

Anonymous
Not applicable

caddzone, thank you for the answer, but I don't understand, how Invoke() method of Application object can be used. Application object available from any thread, and I can use Alert() method from other thread, for example.

Please explain how I can use invoke() method. Maybe you can give a sample.

0 Likes
Message 4 of 6

Anonymous
Not applicable

I already said that you can't call Invoke() from another thread.

 

It can only be called from the document exection context.

0 Likes
Message 5 of 6

Anonymous
Not applicable

I've solved this problem by calling ActiveX SendCommand method from my background thread. But it's very odd solution - call AutoCAD by ActiveX from self!

 

I think it's important to implement invoking commands and methods from other threads in AutoCAD. maybe, not from Document.Editor, maybe from Application object, but multithreading is important now. It's useful in huge area - from parallel computing to AJAX-like interfaces.

0 Likes
Message 6 of 6

Anonymous
Not applicable
Accepted solution

Also I've found another solution. I can implement multithreading via windows form and it's Invoke() method. Form loads in autodesk thread, so I can access object model from form methods. Other threads call Invoke() method.

0 Likes