Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React on Visual Studio Stop

Is there the possibility to run some code when the Code is stopped when running it from Visual Studio?

I am using the CefGlue library to build a WinForms application and realized that there are issues when pressing the stop button ranging from Exception to two windows with no content opening. A separate process continues to run in the background. In order to stop Cef nicely I need to exectue CefRuntime.Shutdown(); Maybe this is because it does not run the application in a Visual Studio hosting process, because CefGlue has problem with this (see this). This does not affect production but is nasty while developing and testing, but nevertheless I would like to execute some code to fix the problem.

I would guess this is not possible but if it was it would be interesting to know.

So I am looking for a way to execute some code when Visual Studio is stopping the application when pressing the stop button while in development.

Note: I am using Visual Studio 2013 and 2015.

Edit The issue is not reproducibly with very few lines of code. Nevertheless I have tried to create a simplified example here

like image 900
Sjoerd222888 Avatar asked Nov 09 '22 21:11

Sjoerd222888


1 Answers

What you're basicly looking for is a solution using the Visual Studio SDK.

You can build your own add-ins by implementing the IDTExtensibility interface.

In the OnConnection function you can subscribe to different events. Using (DTE2)application you can access a lot of things from VS.

You'll have to subscribe to some of the events that can be obtained from the Events property.

You'll have to find out yourself what events work best for your solution. But the DebuggerEvents would seem like a good place to start.

This does require some research before you can use it. There are likely to be easier solutions.

As a simple example for the OnConnection:

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    var applicationObject = (DTE2)application;

    var events = _applicationObject.Events;
    var buildEvents = (BuildEvents)events.BuildEvents;
    buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(OnBuildBegin);
}

This triggers when a build is started. The available documentation isn't great, so it will need some trial-and-error before you find what you need.

like image 50
Chrono Avatar answered Nov 14 '22 22:11

Chrono