diff --git a/src/AddIns/Misc/Profiler/Controller/Queries/QueryCompiler.cs b/src/AddIns/Misc/Profiler/Controller/Queries/QueryCompiler.cs index 239ed4e942..75fb79a8c4 100644 --- a/src/AddIns/Misc/Profiler/Controller/Queries/QueryCompiler.cs +++ b/src/AddIns/Misc/Profiler/Controller/Queries/QueryCompiler.cs @@ -76,17 +76,19 @@ namespace ICSharpCode.Profiler.Controller.Queries if (string.IsNullOrEmpty(this.currentQuery)) return false; - if (!queryCache.ContainsKey(this.currentQuery)) { - string code = text + PreprocessString(currentQuery) + textEnd; - CompilerResults results = csc.CompileAssemblyFromSource(GetParameters(), code); - report(results.Errors.Cast()); - - if (results.Errors.Count > 0) - return false; - - queryCache.Add(this.currentQuery, results.CompiledAssembly); - } else { - report(new List().AsEnumerable()); // clear errors list + lock (queryCache) { + if (!queryCache.ContainsKey(this.currentQuery)) { + string code = text + PreprocessString(currentQuery) + textEnd; + CompilerResults results = csc.CompileAssemblyFromSource(GetParameters(), code); + report(results.Errors.Cast()); + + if (results.Errors.Count > 0) + return false; + + queryCache.Add(this.currentQuery, results.CompiledAssembly); + } else { + report(new List().AsEnumerable()); // clear errors list + } } return true; diff --git a/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs b/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs index 61cd9a3942..9570520ac9 100644 --- a/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs +++ b/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs @@ -148,9 +148,10 @@ namespace ICSharpCode.Profiler.Controls layer.Add(ad); int rangeStart = RangeStart; int rangeEnd = RangeEnd; + string query = this.CurrentQuery; ProfilingDataProvider provider = Provider; - QueryCompiler compiler = new QueryCompiler(Reporter, this.CurrentQuery); + QueryCompiler compiler = new QueryCompiler(Reporter, query); ringDiagram.SelectedRoot = null; task.Execute(() => LoadWorker(provider, compiler, rangeStart, rangeEnd),