Avoid going to any immigration offices within Thailand (not at border crossings). I have heard of immigration officers cancelling people’s DTV if they work out that you were inside Thailand when it was issued. Immigration at the airport or other border crossings on arrival could do the same. But they are less likely to scrutinise the passport since they have less time. It’s still a risk but you have no other option.