提交 9ced9c1f 编写于 作者: J Jason Malinowski

Ensure we don't leak an event handler forever

It's not clear to me if the IAttachedCollectionSource API gives you
any way to know if your collection isn't being needed anymore; for now
this ensures we clean up once the project is removed.
上级 bcbfaaef
......@@ -191,11 +191,15 @@ public void BeforeExpand()
}
public void AfterCollapse()
{
StopUpdating();
}
private void StopUpdating()
{
lock (_gate)
{
Contract.ThrowIfNull(_cancellationTokenSource, "We created a token when we expanded, how do we not have one when collapsing?");
_cancellationTokenSource.Cancel();
_cancellationTokenSource?.Cancel();
_cancellationTokenSource = null;
_workspace.WorkspaceChanged -= OnWorkpaceChanged;
_resettableDelay = null;
......@@ -204,6 +208,11 @@ public void AfterCollapse()
private void OnWorkpaceChanged(object sender, WorkspaceChangeEventArgs e)
{
if (!e.NewSolution.ContainsProject(_parentGeneratorItem.ProjectId))
{
StopUpdating();
}
lock (_gate)
{
// If we already have a ResettableDelay, just delay it further; otherwise we either have no delay
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册