Pablo Galiano : How do I flush content to the Visual Studio output window

Subscriptions

<March 2010>
SuMoTuWeThFrSa
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

News

Subscribe to Pablo Galiano by Email

Post Categories

How do I flush content to the Visual Studio output window

My fifth How do I is up.

Scenario

Every time that we write to the Visual Studio output window, the content is not flushed automatically. Sometimes this can be resolved by the Application.DoEvents(); call. But this method doesn't work in a number of scenarios. The focus of this How do I tackles how to approach this problem.

 

Interfaces and classes needed

 

Code snippet

Automation way

    DTE2 dte = serviceProvider.GetService(typeof(SDTE)) as DTE2;

 

    OutputWindowPane generalPane =

        dte.ToolWindows.OutputWindow.OutputWindowPanes.OfType<OutputWindowPane>()

            .FirstOrDefault(pane =>

                new Guid(pane.Guid).Equals(VSConstants.GUID_OutWindowGeneralPane));

 

    if(generalPane != null)

    {

        generalPane.OutputString("Test");

        generalPane.ForceItemsToTaskList();

    }

Assemblies needed

  • EnvDTE
  • EnvDTE80

Interop way

    IVsOutputWindow outputwindow = serviceProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;

 

    Guid generalGuidPane = VSConstants.GUID_OutWindowGeneralPane;

    IVsOutputWindowPane generalPane;

 

    ErrorHandler.ThrowOnFailure(outputwindow.GetPane(ref generalGuidPane, out generalPane));

    generalPane.OutputStringThreadSafe("Test");

    ErrorHandler.ThrowOnFailure(generalPane.FlushToTaskList());

 

Assemblies needed

  • Microsoft.VisualStudio.Shell.Interop
  • Microsoft.VisualStudio.Shell.9.0

 

Stay tuned,

Pablo

posted on Wednesday, August 20, 2008 6:48 AM by pga

What do you think?

(required) 
required 
optional
required