Progress indicator

I would like to know how others handle the display of a "Progress indicator " in a web application.

Because if I call (Psuedocode)

Show DIalog
Do work
Hide dialog

It all gets done at once and the user never sees the progress indicator.

So, I was using a series of timers that were string to gather as follows

Timer 1 --> Show a dialog with the progress wheel on it and then calls timer 2

Timer 2 --> Do the work, update the page and call timer three

Timer 3–> calls hide the progress wheel.

But optimizing the timers is a black art in this case.

How do others handle giving the user an indication that “the app is grinding away: hang on for 4 or 5 seconds” ?

Example Projects/Web/Controls/ProgressBar

Also this discussion might be valuable to you as well - http://forums.realsoftware.com/viewtopic.php?f=23&t=44764