提交 7b159710 编写于 作者: H Heejae Chang 提交者: GitHub

Merge pull request #16376 from heejaechang/defaultSessionOnUI

make sure we initialize TelemetryHelper from UI threads before we usi…
using System;
using System.ComponentModel.Composition;
using System.Diagnostics;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Options;
using Microsoft.Internal.VisualStudio.Shell;
using Microsoft.Internal.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.LanguageServices;
using Microsoft.VisualStudio.LanguageServices.Setup;
namespace Microsoft.VisualStudio.LanguageServices.Telemetry
{
......@@ -18,6 +15,13 @@ public static void Initialize(IServiceProvider serviceProvider)
var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
var optionService = componentModel.GetService<IGlobalOptionService>();
// Fetch the session synchronously on the UI thread; if this doesn't happen before we try using this on
// the background thread then we will experience hangs like we see in this bug:
// https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?_a=edit&id=190808 or
// https://devdiv.visualstudio.com/DevDiv/_workitems?id=296981&_a=edit
var unused1 = TelemetryHelper.TelemetryService;
var unused2 = TelemetryHelper.DefaultTelemetrySession;
var telemetryService = serviceProvider.GetService(typeof(SVsTelemetryService)) as IVsTelemetryService;
Logger.SetLogger(
AggregateLogger.Create(
......
......@@ -30,11 +30,6 @@ public VSTelemetryActivityLogger(IVsTelemetryService service) : base(assertIsFor
{
_service = service;
_pendingActivities = new ConcurrentDictionary<int, TelemetryActivity>(concurrencyLevel: 2, capacity: 10);
// Fetch the session synchronously on the UI thread; if this doesn't happen before we try using this on
// the background thread then we will experience hangs like we see in this bug:
// https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workitems?_a=edit&id=190808
var unused = TelemetryHelper.DefaultTelemetrySession;
}
public bool IsEnabled(FunctionId functionId)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册