fixed the issue with resources not disposed correctly (#439)

* fixed the issue with resources not disposed correctly

* disposing language service at shutdown
This commit is contained in:
Leila Lali
2017-08-21 14:32:48 -07:00
committed by GitHub
parent 39dedd88e0
commit 1511f73672
7 changed files with 108 additions and 71 deletions

View File

@@ -14,7 +14,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
/// <summary>
/// Main class for the Binding Queue
/// </summary>
public class BindingQueue<T> where T : IBindingContext, new()
public class BindingQueue<T> : IDisposable where T : IBindingContext, new()
{
private CancellationTokenSource processQueueCancelToken = new CancellationTokenSource();
@@ -313,5 +313,24 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
}
}
}
public void Dispose()
{
if (itemQueuedEvent != null)
{
itemQueuedEvent.Dispose();
}
if (this.BindingContextMap != null)
{
foreach (var item in this.BindingContextMap)
{
if (item.Value != null && item.Value.ServerConnection != null && item.Value.ServerConnection.SqlConnectionObject != null)
{
item.Value.ServerConnection.SqlConnectionObject.Close();
}
}
}
}
}
}