I have had my 40D for 20 months now and have done about 14000 shots. I moved up from a 350D and keep that for a 2nd camera.
The 40D is sold by canon as a level above the 350/400D and it certainly is. Much better iso usability, faster autofocus, much better feel in the hands and far more true colour.
I have found that 800 iso is not sharp but probably usable to print 6 x 4 prints, but 1000 iso and above should only be used when you can't get the shot any other way.
I think my next camera will probably be a 5D mark 1 as I am expecting better iso capabilities with that even though it is older technology with a smaller screen and no iso idicator in the viewfinder. As an amateur, I can't justify the mk11 just yet.
I think the 40D will remain with me for quite a while as the backup camera, especially in well lit places. I have learnt how to use the 580ex11 well enough when it is possible to bounce and keep the iso down, but that is not always possible.
I haven't owned a 50D, but doubt the image quality would be any better than the 40D. It, of course, has newer technologhy, better screen, more pixels and video but a good 2nd hand 40D will continue to be great value for a while yet. I think the next level is a full frame, not the 7D.