AutoCAD JavaScript asynchronous Application Programming Interface (APIs) follow a promise pattern, which does not block and wait for the long-running computation to complete, instead the pattern returns an object which represents the promised result.
AutoCAD JavaScript asynchronous APIs uses a promise base class. A promise implements a method for registering callbacks for state change notifications, commonly named the then method. The then() method that takes 2 callbacks: success() and error() as shown in the sample code:
Acad.Application.activedocument.capturePreview(200,200).then(success,error);
The benefits of asynchronous APIs can be summarized as:
These benefits allow you to better harness the parallelism in your system.