private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { var selection = (string)e.AddedItems.SingleOrDefault(); if (selection == null || _points.ContainsKey(selection)) { return; } var(info, port) = Global.Instance.Receiver.Ports.Single(it => it.Key.ToString() == selection); port.LinkTo(new ActionBlock <List <Vector3> >( frame => { var topic = info.ToString(); var list = _points.GetOrAdd(topic, _ => new List <Vector3>()); var config = _configs.GetOrAdd(topic, _ => { var it = new GraphicConfig(topic) { ShowCount = ViewModelContext.DefaultConfig.ShowCount, SaveCount = ViewModelContext.DefaultConfig.SaveCount, Background = ViewModelContext.DefaultConfig.Background, Connect = ViewModelContext.DefaultConfig.Connect }; it.PropertyChanged += (__, ___) => Canvas2D.Invalidate(); var ____ = MainList.Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Normal, () => { MainList.Items?.Add(it); MainList.SelectedItems.Add(it); }); return(it); }); if (ViewModelContext.Frozen) { return; } lock (list) { if (info.Type == GraphType.Frame) { list.Clear(); } list.AddRange(frame); var verbose = list.Count - _configs[topic].SaveCount; if (verbose > 0) { list.RemoveRange(0, verbose); } } Canvas2D.Invalidate(); }), new DataflowLinkOptions()) .Also(_links.Add); }