void RunRows(CancellationToken token, Heartbit hrt) { while (!token.IsCancellationRequested) { Rows = hrt.Get(Current, 100); Current++; if (Current == uint.MaxValue) { Current = 0; } if (!token.IsCancellationRequested) { Thread.Sleep(Freq); } } }
public MainWindowViewModel() { cncl = new CancellationTokenSource(); var hrt = new Heartbit(() => new RawData()); Rows = hrt.Get(0, 10); Freq500 = true; var dep = new DependencyObject(); if (!DesignerProperties.GetIsInDesignMode(dep)) { var rows = hrt.Get(0, 50); var action = false ? new Action(() => RunRows(cncl.Token, hrt)) : new Action(() => RunRowUpdate(cncl.Token, hrt, rows)); RunTask = Task.Run(action); } }
void RunRowUpdate(CancellationToken token, Heartbit hrt, ObservableCollection <IRawData> rows) { Rows = rows; while (!token.IsCancellationRequested) { Current++; if (Current == uint.MaxValue) { Current = 0; } uint q = 0; foreach (var rd in Rows) { hrt.SetItem(rd, q++ + Current); } if (!token.IsCancellationRequested) { Thread.Sleep(Freq); } } }