How can I modify the "main" method of a T4 text template to be async and make calls to other async methods using await?
Or is my only choice to call these methods synchronously (and if so, what's the best way?)
How can I modify the "main" method of a T4 text template to be async and make calls to other async methods using await?
Or is my only choice to call these methods synchronously (and if so, what's the best way?)
AFAIK there is no way to instruct a T4 template to run in async mode. That leaves you the option to do the following, which I found is the best way to run an async method from a regular method (it preserves the ability to catch exceptions):
Task.Run(() => YourMethod(arg)).Wait();