My mechanic measured the rim off my front wheel to be 0.8mm thick and recommended to get a new wheel. How thin can a rim get until it gets very dangerous to keep riding it?
0.8mm is very thin and dangerous. The mechanic is right to tell you to replace the rim! Keep it only if you want to play with your life because it may fail in a catastrophic manner! More dangerous even on a front wheel.
Many rims have wear indicators, usually a couple of holes along the braking surfaces, that tell you that the rim is over the limit once one of the holes becomes invisible.
I don't know exact numbers, but you will know when you need to replace your wheel when the rim starts to have a concave feel to it when you run your fingers over it (I'm talking about aluminum rims here). An extremely bad case will look something like this:
Don't let your rim ever get here, but this is a good example of what your rim will do if you let it go. Letting it go this far can lead to a pretty nasty crash, especially if it's your front tire. It's basically like riding on a ticking time bomb, as the wheel could give out any second.
You can definitely feel when your rim starts to become concave before you see it, and when you do feel that, it is time to replace your wheel.
On some wheels, there is a little hole called a wear indicator hole. I'm not sure if you ever noticed it on your rim, but if that gets worn away and you can no longer see it, it is also time to replace your wheel.