If the cause of this on your machine is the same as on mine, I know why it happens and a (fairly awkward) workaround.
My MacBook does this whenever some process runs away with all the CPU cycles, sometimes it takes ages to properly wake up and log in and sometimes it doesn't manage it at all.
The work-around is to SSH in from another machine and kill the process that's hogging the CPU. Your MacBook will spring back to life! (Assuming, as I said, that we are experiencing the same issue - I only know for sure that we are experiencing the same symptoms)
If this does prove to be the cause, if you know or suspect a process is going to use a lot of CPU, to keep the system stable and perky you can either launch it from the command-line with "nice", e.g.
$ nice ./some_beastly_script.pl
Or if the process is already running, you can "renice" it:
$ renice $PID
Both of these will give that process lower CPU priority, stopping it bogging down other things.
I've mean meaning to look into the possibility of making essential things like the screensaver / unlock / core OS bits have higher priority than anything else, I'll write it up if I figure anything out.