void Initialize() { if (_isDumpFile) { this.LoadFromFile(); } if (_funcGetItems != null) { var lst = _funcGetItems(); if (lst != null) { foreach (var t in lst) { this.Items.TryAdd(t.Id, t); } OnItemListUpdated?.Invoke(this, this.Items.Values.ToList()); } } }
private void UpdateFromServer() { lock (this) { if (_isProcessItemBusy) { return; } _isProcessItemBusy = !_isProcessItemBusy; } Task.Run(() => { try { //this.LogDebug("pull balance"); if (_funcGetItems != null) { var lst = _funcGetItems(); if (lst != null) { Items.Clear(); foreach (var t in lst) { this.Items.TryAdd(t.Id, t); } OnItemListUpdated?.Invoke(this, this.Items.Values.ToList()); } } } finally { _isProcessItemBusy = !_isProcessItemBusy; } }); }