Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/03/15 00:03:18 (9 years ago)
Author:
aballeit
Message:

#2283 limit parallelism

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/Evaluation/MainWindow.xaml.cs

    r12830 r12832  
    33using System.Text;
    44using System.Threading;
     5using System.Threading.Tasks;
    56using System.Windows.Documents;
    67using System.Xml.Serialization;
     
    4546            vm.MaxIterations = 500000;
    4647            vm.NrRuns = 20;
     48            vm.MaxThreads = 5;
    4749        }
    4850
     
    126128                    //    File.WriteAllBytes(run.SvgFile, mctsSolver.GenerateSvg());
    127129                    //}
     130                    mctsSolver.FreeAll();
    128131                }
    129132            }
     
    183186            }
    184187
     188
     189
    185190            for (int i = 0; i < vm.NrRuns; i++)
    186191            {
     
    218223
    219224                vm.Runs.Add(run);
    220 
    221                 ThreadPool.QueueUserWorkItem(DoRun, run);
    222             }
     225            }
     226            Task.Run(() =>
     227                Parallel.For(0, vm.NrRuns, new ParallelOptions {MaxDegreeOfParallelism = vm.MaxThreads},
     228                    i => DoRun(vm.Runs[i])));
    223229        }
    224230
Note: See TracChangeset for help on using the changeset viewer.