I based mine on time passed, that way it doesn't matter how fast your machine is.  This code waits 20 seconds before it gives up.  Note that if it does get a good zone id, it breaks out of the loop.
	Code:
	__time64_t curtime1,curtime2;
_time64(&curtime1);      
do
{            
   charid = database.GetCharacterInfo(char_name, &tmpaccid, &zoneID);            
   _time64(&curtime2);
}while(curtime2 - curtime1 <= 20 && zoneID == 0);