The straight forward zul code here is using the Simple Long Operation View Model and posting the start Long Operation-command To update the UI during a long operation the desktop needs to be activated for UI updates.

It can be used with both MVC and MVVM (while the examples here use MVVM it should be obvious that the same code can be implemented in an MVC event listener).

The Long Operation class provides a basic abstraction over the required ZK and Java Threading details to handle a (cancellable) long running operation using Server Push to give feedback to the user - during and after the operation.

Referring to Cancellable Long Operation View Model / you can cancel a long operation and give user feedback accordingly.

The Long Operation will naturally terminate (calling on Cancel) when the thread was interrupted, or by checking explicitly for cancellation between steps, in case the Long Operation was cancelled during a blocking method call.

2 seconds) I consider it a "Long Operation" that requires some feedback to either keep the user waiting, while giving status updates, and ideally let the user still interact with the UI while the operation is running.

That requires to run the task in the background on the server without blocking the UI, or blocking the UI (or parts of it) and inform the user about the estimated duration, or the percentage of completeness as a few examples.

Here's the C# code that uses P/Invoke, which should work for Auto CAD 20: And here's what you see when it runs: Update: Thanks to Chris Bray for pointing out the above technique (and the one I was about to show in Part 2) is unnecessary from Auto CAD 2007 onwards. I'll forego the Part 2 post (and rename this one from Part 1), as there's really no need to look any other technique for this, at this stage.

A new class was introduced in Auto CAD 2007 called Autodesk.

The class will take care of starting/stopping Server Push to save resources when no Long Operation is active.