public Task LoadAndRunBatch(string[] args) { Load(); BenchmarkItem[] activeBenchmarks = BenchmarkItem.GetActive(benchmarks, args); var dispatcher = this.GetRequiredService <IDispatcherService>(); var awaiter = this.GetService <IUIAwaiter>(); this.batchTotal = activeBenchmarks.Length; return(Task.Factory.StartNew(() => { int total = 0; for (int i = 0; i < activeBenchmarks.Length; i++) { this.batchIndex = i + 1; var current = activeBenchmarks[i]; total = UIOperation <int>(dispatcher, () => { ActiveHostItem = HostItems.FirstOrDefault(host => BenchmarkItem.IsBenchmarkFor(current.Type, host.Name)); if (ActiveHostItem != null) { ActiveBenchmarkItem = current; } return total + ((ActiveHostItem != null) ? 1 : 0); }).ContinueWith(tSelectItem => { Run().Wait(); return tSelectItem.Result; }).Result; } this.batchTotal = null; this.batchIndex = null; dispatcher.BeginInvoke(() => OnBatchRunComplete(total)); })); }
protected virtual void OnActiveHostItemChanged() { var hostService = this.GetService <IHostService>(); if (hostService != null) { hostService.Show(ActiveHostItem.Target); } // if (ActiveHostItem == null) { BenchmarkItems = new List <BenchmarkItem>(); } else { BenchmarkItems = benchmarks .Where(x => BenchmarkItem.IsBenchmarkFor(x.Type, ActiveHostItem.Name)) .ToList(); } }