/// <summary> /// Determines if we are completely done with this submission and can complete it so the user may access results. /// </summary> private void CheckForCompletion() { if (BuildResult != null && LoggingCompleted) { bool hasCompleted = (Interlocked.Exchange(ref _completionInvoked, 1) == 1); if (!hasCompleted) { // Did this submission have warnings elevated to errors? If so, mark it as // failed even though it succeeded (with warnings--but they're errors). if (((IBuildComponentHost)BuildManager).LoggingService.HasBuildSubmissionLoggedErrors(BuildResult.SubmissionId)) { BuildResult.SetOverallResult(overallResult: false); } _completionEvent.Set(); if (_completionCallback != null) { void Callback(object state) { _completionCallback(this); } ThreadPoolExtensions.QueueThreadPoolWorkItemWithCulture(Callback, CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture); } } } }