Retrieve Result from Asynchronous Command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am writing a netloaded dll for AutoCad which needs to invoke several Lisp commands (inbuilt Autocad Electrical commands such as wd_insym2), retrieve the returned result and stores it in a local .Net variable (a property of a custom class), then continue with the next command.
As it is one continuous execution, and each command often relies on the result of the previous command, ideally the commands would run synchronously. I have been using Application.Invoke() which is fairly effective for most commands, however some particular commands such as wd_insym2 seem to run additional commands such as UNDO, and it gives me errors like:
AutoCAD command rejected: "_.UNDO"
which someone explained to me was due to reentrancy issues whereby my command calls the Electrical command, which in turn calls other commands such as UNDO, which is giving me the error. Can you confirm this is correct?
However, I can't see how I can do this with asynchronous commands. I tried using the doc.CommandEnded handler, and putting the .NET command into a loop until the doc.CommandEnded handler was activated, but that didn't work because the asynchronous commands were never executed.
I need a way of either satisfactorily executing commands synchronously, or alternatively pausing execution until the asynchronous command is executed.
Be gald of anyone's assistance/advice.