First of all, welcome to our community!
Asylum proceedings in the EU are regulated by the so called Dublin III convention. If you apply for asylum in Germany they will check if they are responsible in accordance with Dublin III first. If, for example, another EU-member state granted you a visa (or a residency permit) than German authorities can use this as a reason to decline your application. But I am not sure in how far this is applicable if the visa is granted by a non-EU state (and if it is just a visitor visa) to be honest.
So can you tell us which third country granted you a visa, please? If it's not a EU-member state, other regulations might apply.
In addition to my answer I will link @Marcel and @Steven