Receiving events from VS service in VSIX extension right from IDE startup

379 Views Asked by At

I am trying to create a Visual Studio Extension that closes the least recently used documents. In order to achieve this I need to be able to track when a document has been last used. The way I am doing this is registering a RDT table listener (AdviseRunningDocTableEvents) in the Package::Initialize method. However, this only gets executed when I first run the 'cleanup' command.

Is there a way to register a listener for the RDT table that would be receiving events right from the VS startup? Bearing in mind that I need to access VS services, where would the proper place for such code be?

1

There are 1 best solutions below

0
On BEST ANSWER

A package can be set to autoload in a particular user interface context, for example, when a solution is open.

The ProvideAutoLoadAttribute attribute sets this context.

....
[ProvideAutoLoad(UIContextGuids80.SolutionExists)] // choose when you want it to be loaded
...
public class MyAutoloadedPackage : Package  
{
    ...
}