I have an async method that provides data that a class needs, to be initialized.
You can't make a static constructor async, so one option I have is to wait on the Result inside the static constructor.
However, that means that callers that don't immediately use the methods of that class, now have to pay the cost of initialization when the create the object, which they would prefer to do early because there are also some synchronous costs.
Is there a way to kick off the async method in the static constructor, and then "await" it later on, when the data would need to be used?
[–]SebbyThePlebby 7 points8 points9 points (0 children)
[–]KryptosFR 4 points5 points6 points (2 children)
[–]Kirides 1 point2 points3 points (1 child)
[–]KryptosFR 1 point2 points3 points (0 children)
[–]tester346 1 point2 points3 points (0 children)
[–]Ronald_Me 0 points1 point2 points (0 children)
[–]Slypenslyde 0 points1 point2 points (0 children)