コード例 #1
0
 private void runTests()
 {
     try
     {
         BrowserGuiData.IsBusy = true;
         BrowserGuiData.SampleControlVisibility = Visibility.Hidden;
         using (var parallelTasksQueue = new ParallelTasksQueue(Environment.ProcessorCount))
         {
             var waitingList = new List <Task>();
             for (var i = 0; i < samplesListInternal.Count; i++)
             {
                 var    sample = samplesListInternal[i];
                 Action action = () => runSample(sample);
                 var    task   = Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, parallelTasksQueue);
                 waitingList.Add(task);
             }
             Task.WaitAll(waitingList.ToArray());
         }
     }
     //catch (Exception ex)
     //{
     //    MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     //}
     finally
     {
         BrowserGuiData.IsBusy = false;
         BrowserGuiData.SampleControlVisibility = Visibility.Visible;
     }
 }
コード例 #2
0
ファイル: BrowserViewModel.cs プロジェクト: VahidN/PdfReport
 private void runTests()
 {
     try
     {
         BrowserGuiData.IsBusy = true;
         BrowserGuiData.SampleControlVisibility = Visibility.Hidden;
         using (var parallelTasksQueue = new ParallelTasksQueue(Environment.ProcessorCount))
         {
             var waitingList = new List<Task>();
             for (var i = 0; i < samplesListInternal.Count; i++)
             {
                 var sample = samplesListInternal[i];
                 Action action = () => runSample(sample);
                 var task = Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, parallelTasksQueue);
                 waitingList.Add(task);
             }
             Task.WaitAll(waitingList.ToArray());
         }
     }
     //catch (Exception ex)
     //{
     //    MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     //}
     finally
     {
         BrowserGuiData.IsBusy = false;
         BrowserGuiData.SampleControlVisibility = Visibility.Visible;
     }
 }