/// <summary> /// Starts the IPC server for the Integration Test service. /// </summary> private void StartServiceCallback(object sender, EventArgs e) { if (_startMenuCmd.Enabled) { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainAssemblyResolve; TestTraceListener.Install(); _service = new IntegrationService(); _serviceChannel = new IpcServerChannel( name: $"Microsoft.VisualStudio.IntegrationTest.ServiceChannel_{Process.GetCurrentProcess().Id}", portName: _service.PortName, sinkProvider: DefaultSinkProvider ); var serviceType = typeof(IntegrationService); _marshalledService = RemotingServices.Marshal(_service, serviceType.FullName, serviceType); _serviceChannel.StartListening(null); var componentModel = ServiceProvider.GetService <SComponentModel, IComponentModel>(); var asyncCompletionTracker = componentModel.GetService <AsyncCompletionTracker>(); asyncCompletionTracker.StartListening(); SwapAvailableCommands(_startMenuCmd, _stopMenuCmd); } }
/// <summary> /// Starts the IPC server for the Integration Test service. /// </summary> private void StartServiceCallback(object sender, EventArgs e) { if (_startMenuCmd.Enabled) { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainAssemblyResolve; TestTraceListener.Install(); _service = new IntegrationService(); _serviceChannel = new IpcServerChannel( name: $"Microsoft.VisualStudio.IntegrationTest.ServiceChannel_{Process.GetCurrentProcess().Id}", portName: _service.PortName, sinkProvider: DefaultSinkProvider ); var serviceType = typeof(IntegrationService); _marshalledService = RemotingServices.Marshal(_service, serviceType.FullName, serviceType); _serviceChannel.StartListening(null); // Async initialization is a workaround for deadlock loading ExtensionManagerPackage prior to // https://devdiv.visualstudio.com/DevDiv/_git/VSExtensibility/pullrequest/381506 _ = Task.Run(async() => { var componentModel = (IComponentModel?)await AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(false); Assumes.Present(componentModel); var asyncCompletionTracker = componentModel.GetService <AsyncCompletionTracker>(); asyncCompletionTracker.StartListening(); }); SwapAvailableCommands(_startMenuCmd, _stopMenuCmd); } }
/// <summary> /// Starts the IPC server for the Integration Test service. /// </summary> private void StartServiceCallback(object sender, EventArgs e) { if (_startMenuCmd.Enabled) { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainAssemblyResolve; TestTraceListener.Install(); _service = new IntegrationService(); _serviceChannel = new IpcServerChannel( name: $"Microsoft.VisualStudio.IntegrationTest.ServiceChannel_{Process.GetCurrentProcess().Id}", portName: _service.PortName, sinkProvider: DefaultSinkProvider ); var serviceType = typeof(IntegrationService); _marshalledService = RemotingServices.Marshal(_service, serviceType.FullName, serviceType); _serviceChannel.StartListening(null); // Async initialization is a workaround for deadlock loading ExtensionManagerPackage prior to // https://devdiv.visualstudio.com/DevDiv/_git/VSExtensibility/pullrequest/381506 _ = Task.Run(async() => { var componentModel = (IComponentModel?)await AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(false); Assumes.Present(componentModel); var asyncCompletionTracker = componentModel.GetService <AsyncCompletionTracker>(); asyncCompletionTracker.StartListening(); #pragma warning disable RS0030 // Do not used banned APIs await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); #pragma warning restore RS0030 // Do not used banned APIs var listenerProvider = componentModel.GetService <IAsynchronousOperationListenerProvider>(); s_runningDocTableEventListener = new RunningDocumentTableEventListener(listenerProvider.GetListener(FeatureAttribute.Workspace)); ErrorHandler.ThrowOnFailure(_runningDocumentTable.AdviseRunningDocTableEvents(s_runningDocTableEventListener, out s_runningDocTableEventListenerCookie)); }); SwapAvailableCommands(_startMenuCmd, _stopMenuCmd); } }