未验证 提交 56748a35 编写于 作者: J Joey Robichaud 提交者: GitHub

Merge pull request #39680 from JoeRobich/fix-uithread-check

Switch some calls to ThreadHelper.ThrowIfNotOnUIThread to something else
......@@ -56,9 +56,8 @@ internal abstract partial class AbstractLegacyProject : ForegroundThreadAffiniti
string externalErrorReportingPrefix,
HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt,
ICommandLineParserService commandLineParserServiceOpt)
: base(threadingContext)
: base(threadingContext, assertIsForeground: true)
{
ThreadHelper.ThrowIfNotOnUIThread();
Contract.ThrowIfNull(hierarchy);
var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
......
......@@ -150,7 +150,7 @@ public VisualStudioWorkspaceImpl(ExportProvider exportProvider, IAsyncServicePro
internal void SubscribeExternalErrorDiagnosticUpdateSourceToSolutionBuildEvents()
{
ThreadHelper.ThrowIfNotOnUIThread();
_foregroundObject.AssertIsForeground();
if (_isExternalErrorDiagnosticUpdateSourceSubscribedToSolutionBuildEvents)
{
......@@ -368,7 +368,7 @@ public override EnvDTE.FileCodeModel GetFileCodeModel(DocumentId documentId)
Microsoft.CodeAnalysis.Solution newSolution,
IProgressTracker progressTracker)
{
if (!ThreadHelper.JoinableTaskContext.IsOnMainThread)
if (!_foregroundObject.IsForeground())
{
throw new InvalidOperationException(ServicesVSResources.VisualStudioWorkspace_TryApplyChanges_cannot_be_called_from_a_background_thread);
}
......@@ -453,7 +453,7 @@ internal override bool CanRenameFilesDuringCodeActions(CodeAnalysis.Project proj
internal bool IsCPSProject(CodeAnalysis.Project project)
{
ThreadHelper.ThrowIfNotOnUIThread();
_foregroundObject.AssertIsForeground();
if (this.TryGetHierarchy(project.Id, out var hierarchy))
{
......@@ -1072,7 +1072,7 @@ public void OpenDocumentCore(DocumentId documentId, bool activate = true)
throw new ArgumentNullException(nameof(documentId));
}
if (!ThreadHelper.JoinableTaskContext.IsOnMainThread)
if (!_foregroundObject.IsForeground())
{
throw new InvalidOperationException(ServicesVSResources.This_workspace_only_supports_opening_documents_on_the_UI_thread);
}
......@@ -1425,7 +1425,7 @@ public void EnsureEditableDocuments(params DocumentId[] documents)
internal override bool CanAddProjectReference(ProjectId referencingProject, ProjectId referencedProject)
{
ThreadHelper.ThrowIfNotOnUIThread();
_foregroundObject.AssertIsForeground();
if (!TryGetHierarchy(referencingProject, out var referencingHierarchy) ||
!TryGetHierarchy(referencedProject, out var referencedHierarchy))
{
......
......@@ -58,8 +58,6 @@ public bool LastDesignTimeBuildSucceeded
public CPSProject(VisualStudioProject visualStudioProject, VisualStudioWorkspaceImpl visualStudioWorkspace, IProjectCodeModelFactory projectCodeModelFactory, Guid projectGuid, string binOutputPath)
{
ThreadHelper.ThrowIfNotOnUIThread();
_visualStudioProject = visualStudioProject;
_visualStudioWorkspace = visualStudioWorkspace;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册