protected string GetCombinedScriptsSource() { List <string> scriptPaths = GetScriptPaths(); StringBuilder objStrBuilder = new StringBuilder(); objStrBuilder.Append(_handlerPath); foreach (string sPath in scriptPaths) { ScriptElement element = null; string fullElementPath = ResolveUrl(sPath); if (!fullElementPath.Contains(HttpRuntime.AppDomainAppVirtualPath)) { //make sure to get full path with application root fullElementPath = HttpRuntime.AppDomainAppVirtualPath + fullElementPath; } element = OptimizerConfig.GetScriptByPath(fullElementPath); if (element != null) { objStrBuilder.Append(element.Key + "."); } } string strPath = objStrBuilder.ToString(); if (strPath.EndsWith(".")) { //remove last unnecessary "." strPath = strPath.Substring(0, strPath.LastIndexOf(".")); } return(strPath); }
private void OnAlgorithmStart() { StartButtonEnable = false; var config = new OptimizerConfig() { UseDelay = UseDelay, DelayTime = Convert.ToInt32(DelayTime), NumberOfCores = Convert.ToInt32(NumberOfCores), CoolingRate = Convert.ToDouble(CoolingRate, CultureInfo.InvariantCulture), UseBigValleySearch = UseBigValleySearch, PopulationSize = Convert.ToInt32(PopulationSize), CrossoverRate = Convert.ToDouble(CrossoverRate, CultureInfo.InvariantCulture), BigValleySearchRate = Convert.ToDouble(BigValleySearchRate, CultureInfo.InvariantCulture) }; ITspOptimizer optimizer = TspOptimizerFactory.Create(SelectedOptimizer, _shuffledTour, _euclideanPath, config); if (optimizer == null) { Info = "Algorithm not yet implemented :-("; return; } optimizer.OptimizerInfo.Subscribe(UpdateInfo); optimizer.OptimalSequence.Subscribe(PlotTour); _tokenSource = new CancellationTokenSource(); CancellationToken token = _tokenSource.Token; var context = TaskScheduler.FromCurrentSynchronizationContext(); Info = "Optimizer started..."; Task task = Task.Factory.StartNew(() => { optimizer.Start(token, UpdatePathLength); }, token).ContinueWith((t) => { Info = "Optimizer canceled..."; StartButtonEnable = true; }, context); }