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

Subscriptions

<September 2010>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

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

# Extensibility How do I by Pablo #5 and #6 @ Thursday, August 21, 2008 3:02 AM

DSL Related: How do I get the model element associated to a shape and vice versa Interfaces and classes

Anonymous