Running a dungeon well is a lot like writing good software.
You gotta cover the conditions. Think "terrorism threat levels" or some such.
When the PC's enter the dungeon, you might assume the occupants are fairly docile. Not attacking unless encountered.
Once some time goes by, some of them are going to figure out that something is going on. In addition, some of them are just wandering around, and likely to encounter the party, especially if they're making noise or not moving.
So assuming a random dungeon with rooms randomly populated (perhaps with Jamis Buck's generator), you'll want a couple of pre-generated wandering encounters for each level of the dungeon.
One encounter would represent a casual encounter, basically it finds the party or the party finds it, but neither was specifically seeking each other out. This encounter will likely have the critter try to run away if it gets hurt too badly. Kinda like a dog checking out a noise in the back yard. If the noise is a bunny, dead bunny. if the noise is a cranky party trying to rest, dead or running away dog.
Another encounter represents the monsters actively seeking out the thing that has been killing other denizens or making lots of noise. This could be a patrol or pack of critters. They may try for active attack or clever entrapment/observation.
A basic rule of thumb: if the party stops moving for a lengthy time, then you MUST change something in the dungeon. A monster moves, a room is cleaned up, the party is tracked down. You can't leave everything static, just because the party isn't doing anything.
Janx