· Chuck Conway · Programming · 1 min read
Running Await in a Constructor
If you must run code in a constructor. I’d look for a different way, but if you must, here’s one way.
If you must run code in a constructor. I’d look for a different way, but if you must, here’s one way:
public class MyClass
{
public MyClass()
{
Task.Run(async () => {
var result = await AsyncActivity();
});
}
}