提交 eac45765 编写于 作者: S Sam Harwell

Update usage of IAsyncLifetime.DisposeAsync to pair with InitializeAsync

上级 3e4cf945
......@@ -61,8 +61,14 @@ public virtual async Task InitializeAsync()
}
}
public Task DisposeAsync()
/// <summary>
/// This method implements <see cref="IAsyncLifetime.DisposeAsync"/>, and is used for releasing resources
/// created by <see cref="IAsyncLifetime.InitializeAsync"/>. This method is only called if
/// <see cref="InitializeAsync"/> completes successfully.
/// </summary>
public virtual Task DisposeAsync()
{
_visualStudioContext.Dispose();
return Task.CompletedTask;
}
......@@ -81,18 +87,17 @@ protected void Wait(double seconds)
Thread.Sleep(timeout);
}
/// <summary>
/// This method provides the implementation for <see cref="IDisposable.Dispose"/>. This method via the
/// <see cref="IDisposable"/> interface (i.e. <paramref name="disposing"/> is <see langword="true"/>) if the
/// constructor completes successfully. The <see cref="InitializeAsync"/> may or may not have completed
/// successfully.
/// </summary>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
try
{
_visualStudioContext?.Dispose();
}
finally
{
_messageFilter.Dispose();
}
_messageFilter.Dispose();
}
}
......
......@@ -22,19 +22,10 @@ public override async Task InitializeAsync()
VisualStudio.InteractiveWindow.SubmitText("#cls");
}
protected override void Dispose(bool disposing)
public override Task DisposeAsync()
{
try
{
if (disposing && VisualStudio != null)
{
VisualStudio.ExecuteCommand(WellKnownCommandNames.Edit_SelectionCancel);
}
}
finally
{
base.Dispose(disposing);
}
VisualStudio.ExecuteCommand(WellKnownCommandNames.Edit_SelectionCancel);
return base.DisposeAsync();
}
[WpfFact]
......
......@@ -22,21 +22,12 @@ public override async Task InitializeAsync()
VisualStudio.Workspace.SetUseSuggestionMode(true);
}
protected override void Dispose(bool disposing)
{
try
{
if (disposing && VisualStudio != null)
{
VisualStudio.Workspace.SetUseSuggestionMode(false);
VisualStudio.InteractiveWindow.ClearReplText();
VisualStudio.InteractiveWindow.Reset();
}
}
finally
{
base.Dispose(disposing);
}
public override Task DisposeAsync()
{
VisualStudio.Workspace.SetUseSuggestionMode(false);
VisualStudio.InteractiveWindow.ClearReplText();
VisualStudio.InteractiveWindow.Reset();
return base.DisposeAsync();
}
[WpfFact]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册