Skip to content

Commit

Permalink
Merge pull request #58395 from CyrusNajmabadi/componentModelAcquire
Browse files Browse the repository at this point in the history
Acquire component model with standard pattern
  • Loading branch information
CyrusNajmabadi authored Dec 17, 2021
2 parents abf38fd + bba724f commit 801ab48
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
{
await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(true);

await TaskScheduler.Default;
_componentModel_doNotAccessDirectly = await this.GetServiceAsync<SComponentModel, IComponentModel>(throwOnFailure: true).ConfigureAwait(false);

await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

_componentModel_doNotAccessDirectly = (IComponentModel)await GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(true);
var shell = (IVsShell7)await GetServiceAsync(typeof(SVsShell)).ConfigureAwait(true);
var solution = (IVsSolution)await GetServiceAsync(typeof(SVsSolution)).ConfigureAwait(true);
cancellationToken.ThrowIfCancellationRequested();
Assumes.Present(_componentModel_doNotAccessDirectly);
Assumes.Present(shell);
Assumes.Present(solution);

Expand Down Expand Up @@ -110,7 +109,7 @@ internal IComponentModel ComponentModel
{
get
{
Contract.ThrowIfNull(_componentModel_doNotAccessDirectly);
Assumes.Present(_componentModel_doNotAccessDirectly);
return _componentModel_doNotAccessDirectly;
}
}
Expand Down

0 comments on commit 801ab48

Please sign in to comment.