Exemplo n.º 1
0
        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());
                }
            }
        }
Exemplo n.º 2
0
        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;
                }
            });
        }