Use a monitor class whit a global instance and which your code keeps up to date (I'm starting, I'm working, I'm at xxx%, I'm done).
The monitor can then decide to show the dialog and keep it current. Later, you can simply replace the dialog with a progress bar in the status bar, for example. Use an interface for the monitor (methods: start(), update(), end(), error(), isAborted()) so you can replace it with something else, too.
You can extend the monitor to wait for 500ms after start() if there is an end() and not show the dialog in this case, etc.
This is how Eclipse does it and it works well.