Lazy<Task<T>> with asynchronous initialization
问题 class Laziness { static string cmdText = null; static SqlConnection conn = null; Lazy<Task<Person>> person = new Lazy<Task<Person>>(async () => { using (var cmd = new SqlCommand(cmdText, conn)) using (var reader = await cmd.ExecuteReaderAsync()) { if (await reader.ReadAsync()) { string firstName = reader["first_name"].ToString(); string lastName = reader["last_name"].ToString(); return new Person(firstName, lastName); } } throw new Exception("Failed to fetch Person"); }); public async Task