static void Main(string[] args) { UnderlyingGenerator dp = new UnderlyingGenerator(); while (UnderlyingGenerator.counter < 32000) { var und = dp.GetUnderlying(); Console.WriteLine($"Path is: {und.Path}, Id is: {und.Id}"); } //while(dp.counter < 3200) //Console.WriteLine() }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { UnderlyingGenerator dp = new UnderlyingGenerator(); Action <int> workMethod = (i) => tc.AddOrUpdate(und, MyData); while (UnderlyingGenerator.counter < 32000) { und = dp.GetUnderlying(); myTree.Dispatcher.BeginInvoke(DispatcherPriority.Background, workMethod, 0); } }