Esempio n. 1
0
        private void InitUILog()
        {
            var transformToText = new TransformBlock <PriceEventArgs, string>(e =>
            {
                return($"{e.TimeStampUtc} {e.Name}: {e.Price}");
            });

            var updateUILog = new ActionBlock <string>(e =>
            {
                if (App.Current != null)
                {
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        if (UpdateLog.Count() == _maxLogSize)
                        {
                            UpdateLog.RemoveAt(_maxLogSize - 1);
                        }
                        UpdateLog.Insert(0, e);
                    });
                }
            });

            _broadcastBlock.LinkTo(transformToText);
            transformToText.LinkTo(updateUILog);
        }
        public void AddToWsUserLog(SeNetworkService.SeUser user, int pos, string action, bool updateUi)
        {
            for (int i = 0; i < UpdateLog.Count; i++)
            {
                if (UpdateLog[i].Index == pos)
                {
                    UpdateLog.RemoveAt(i);
                    break;
                }
            }

            UpdateLog.Add(new UpdateLogEntry(0, user.UserName, pos, action));
            if (updateUi)
            {
                OnUpdateUserLogEntries?.Invoke(null, null);
            }
        }