diff --git a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/BindingQueue.cs b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/BindingQueue.cs index 6058ec42..07623afb 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/BindingQueue.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/BindingQueue.cs @@ -112,6 +112,17 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices } } + /// + /// Checks if a binding context already exists for the provided context key + /// + protected bool BindingContextExists(string key) + { + lock (this.bindingContextLock) + { + return this.BindingContextMap.ContainsKey(key); + } + } + private bool HasPendingQueueItems { get diff --git a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/ConnectedBindingQueue.cs b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/ConnectedBindingQueue.cs index 965d94d2..bd767a7a 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/ConnectedBindingQueue.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/LanguageServices/ConnectedBindingQueue.cs @@ -61,6 +61,11 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices // lookup the current binding context string connectionKey = GetConnectionContextKey(connInfo); + if (BindingContextExists(connectionKey)) + { + // no need to populate the context again since the context already exists + return connectionKey; + } IBindingContext bindingContext = this.GetOrCreateBindingContext(connectionKey); if (bindingContext.BindingLock.WaitOne())