public static IDictionaryAsync <TKey, TValue> DictionaryAsyncStart <TKey, TValue>( NextValueDelegate <TKey, TValue> generate) { return(new DynamicDictionaryAsync <TKey, TValue>(generate)); }
public RollingSeries(RollingMonitor monitor, NextValueDelegate next) { this.monitor = monitor; this.next = next; #region create initial data / lines for (int i = 0; i < monitor.MaintainHistoryCount; i++) { values.Add(0); Line l = new Line() { X1 = i * 1, X2 = i * 1 + 1, Y1 = 0, Y2 = 0, Stroke = this.LineBrush, StrokeThickness = this.lineThickness }; lines.Add(l); monitor.Children.Add(l); } #endregion #region update thread Thread t = new Thread(delegate() { while (true) { #region running if (running) { Thread.Sleep(monitor.UpdateInterval); #region update data values.Add(next()); values.RemoveAt(0); #endregion #region update interface monitor.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new RefreshDelegate(delegate() { for (int i = 0; i < lines.Count - 1 && i < values.Count - 1; i++) { double y1 = Math.Max(Math.Min(values[i], monitor.MaxValue), monitor.MinValue); double y2 = Math.Max(Math.Min(values[i + 1], monitor.MaxValue), monitor.MinValue); lines[i].Y1 = monitor.scaleY(y1); lines[i].Y2 = monitor.scaleY(y2); } })); #endregion } #endregion #region not running state else { try { Thread.Sleep(new TimeSpan(0, 0, 20)); } catch (Exception) { } } #endregion } }); t.Name = "RollingSeries Update"; t.Start(); #endregion monitor.SizeChanged += new SizeChangedEventHandler(Canvas_SizeChanged); Canvas_SizeChanged(this, null); }
public DynamicDictionaryAsync(NextValueDelegate <TKey, TValue> nextAsync) { this.dictionary = new Dictionary <TKey, TValue>(); this.inProgressDictionary = new Dictionary <TKey, Task <ISelectNextValue <TValue> > >(); this.nextAsync = nextAsync; }