There are known issues with the Wifi on a number of Android handsets - possibly just HTC ones.
Google don't seem to be much in a hurry to sort them out. This is a bug which has crippled my Magic for about a year. No sign of a fix. Not sure I'd buy an Android phone again unless I was sure they'd looked at it - shame because everything else is incredible.