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);
        }