/// <summary> /// 异步获取实例 /// </summary> /// <returns></returns> public static async Task <MemoryListViewModel> GetInstanceAsync() { if (_uniqueInstance != null) { return(_uniqueInstance); } lock (Locker) { // 如果类的实例不存在则创建,否则直接返回 if (_uniqueInstance == null) { // ReSharper disable once PossibleMultipleWriteAccessInDoubleCheckLocking _uniqueInstance = new MemoryListViewModel(); } } _uniqueInstance._memoryList = await MemoryList.GetInstanceAsync(); foreach (var memoryModel in _uniqueInstance._memoryList.MemoryModels) { var memoryViewModel = await MemoryViewModel.GetInstanceAsync(memoryModel); _uniqueInstance.MemoryViewModels.Add(memoryViewModel); } return(_uniqueInstance); }