Search code examples
c#.netautocadautocad-pluginautolisp

How to call Lisp functions Asynchronously?


I currently have a .Net C# function which calls and passes a result buffer to a lisp function using Application.Invoke() (see [AutoDesk]). The lisp function I am calling is neither AutoCAD native, nor is it an ARX/.Net function, so I cannot use the Editor.Command/Editor.CommandAsync methods, but the lisp code does call AutoCAD commands within the function. Is there a way to use the Invoke() or another method to call this function, without generating the dreaded AutoCAD command rejected: ... error?


Solution

  • This is not possible.

    The AutoLisp engine is synchronous only. You can use Lisp to call asynchronous commands/functions in ARX/.NET, but not the other way around. Even Task.Run will not perform the Lisp operation once the method exits.

    The best approach is to convert all operations to ARX/.NET. If you want lisp to be a part of it, at least convert the operations that need to be asynchronous to ARX/.NET.