Skip to content

Commit fa3ae7a

Browse files
committed
vsthrd010 logger refactor
1 parent 0b83b9a commit fa3ae7a

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

SharedProject/Impl/Logger.cs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,27 @@ IServiceProvider serviceProvider
3636
staticLogger = this;
3737
}
3838

39-
IVsOutputWindowPane CreatePane(Guid paneGuid, string title,
40-
bool visible, bool clearWithSolution)
41-
{
42-
43-
ThreadHelper.ThrowIfNotOnUIThread();
44-
_outputWindow = (IVsOutputWindow)_serviceProvider.GetService(typeof(SVsOutputWindow));
45-
Assumes.Present(_outputWindow);
46-
dte = (EnvDTE.DTE)_serviceProvider.GetService(typeof(EnvDTE.DTE));
47-
Assumes.Present(dte);
48-
49-
// Create a new pane.
50-
_outputWindow.CreatePane(
51-
ref paneGuid,
52-
title,
53-
Convert.ToInt32(visible),
54-
Convert.ToInt32(clearWithSolution));
55-
56-
// Retrieve the new pane.
57-
_outputWindow.GetPane(ref paneGuid, out IVsOutputWindowPane pane);
58-
return pane;
59-
}
60-
6139
private void SetPane()
6240
{
63-
ThreadHelper.ThrowIfNotOnUIThread();
64-
// do not clear with solution otherwise will not get initialize methods
65-
_pane = CreatePane(fccPaneGuid, "FCC", true, false);
41+
ThreadHelper.JoinableTaskFactory.Run(async () =>
42+
{
43+
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
44+
_outputWindow = (IVsOutputWindow)_serviceProvider.GetService(typeof(SVsOutputWindow));
45+
Assumes.Present(_outputWindow);
46+
dte = (EnvDTE.DTE)_serviceProvider.GetService(typeof(EnvDTE.DTE));
47+
Assumes.Present(dte);
48+
49+
// Create a new pane.
50+
_outputWindow.CreatePane(
51+
ref fccPaneGuid,
52+
"FCC",
53+
Convert.ToInt32(true),
54+
Convert.ToInt32(false)); // do not clear with solution otherwise will not get initialize methods
55+
56+
// Retrieve the new pane.
57+
_outputWindow.GetPane(ref fccPaneGuid, out IVsOutputWindowPane pane);
58+
_pane = pane;
59+
});
6660
}
6761

6862
[SuppressMessage("Usage", "VSTHRD102:Implement internal logic asynchronously")]

0 commit comments

Comments
 (0)