public ShareViewModel GetOrCreate(Guid coinId) { if (!NTMinerRoot.Current.CoinSet.Contains(coinId)) { return(new ShareViewModel(coinId)); } if (_dicByCoinId.ContainsKey(coinId)) { return(_dicByCoinId[coinId]); } ShareViewModel item = new ShareViewModel(coinId); _dicByCoinId.Add(coinId, item); return(item); }
public ShareViewModel GetOrCreate(Guid coinId) { if (!NTMinerRoot.Current.CoinSet.Contains(coinId)) { return(new ShareViewModel(coinId)); } ShareViewModel shareVm; if (!_dicByCoinId.TryGetValue(coinId, out shareVm)) { lock (_locker) { if (!_dicByCoinId.TryGetValue(coinId, out shareVm)) { shareVm = new ShareViewModel(coinId); _dicByCoinId.Add(coinId, shareVm); } } } return(shareVm); }