It might be a limitation of DirectX. When the first app is running in DirectX mode, the main window of the second app is always under the first app. But the first app is waiting for the return of the second app, so you cannot control the first app while the second app is running.
The following code might work
Code:
DirectX.restore();
Shell.runAndWait(...);
DirectX.setDisplayMode(800, 600, 256);