Force progress bar in X++
There are several standard, best practice approaches to showing your user a wait indicator. Such as startLengthyOperation, SysOperationProgress, or even more creative approaches such as a manual Dialog run/close with various options for detach/modal.
However, I found come across many scenarios where these indicators are never shown to the user, depending on the scenario. Most recently, this occurred during a 5-10 second executeQuery. The standard "please wait while..." did not show, but form controls were unresponsive. Trying any of the approaches above never rendered anything to the user. I suspect this was caused by how the kernel is handling threads and updating the user interface, but this is only a guess.
A reliable workaround I have found seems to interrupt the default kernel processing to get a dialog displayed before the lengthy process starts. It will then close once form is responsive again. Note the "time elapsed" will never update on this control if you are using it for this workaround. In the example below, waitForSomething should only take one millisecond to run, but it displayed the entire length of the ExecuteQuery, which is the ideal behavior for this use case.
Step 1: create a dummy method with wait.
public static void waitForSomething(container _con)
{
sleep(1);
}
Step 2: call this method with SysOperationSandbox:
...
SysOperationSandbox::callStaticMethod(classNum(yourClass), staticMethodStr(yourClass, waitForSomething), conNull(), "Loading data...");
...
And you should get a dialog similar to this: