private void RecreateContext() { if ((_ParentService != null) && _NeedsRecreate) { _NeedsRecreate = false; if (_Context == null) { _ParentService.CreateLocalContext(_Priority, true, out _Context, out _Cookie); } else { VSUSERCONTEXTPRIORITY vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_None; switch (_Priority) { case HelpContextType.Ambient: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Ambient; break; case HelpContextType.Window: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Window; break; case HelpContextType.Selection: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_Selection; break; case HelpContextType.ToolWindowSelection: vsusercontextpriority = VSUSERCONTEXTPRIORITY.VSUC_Priority_ToolWndSel; break; } IVsUserContext userContext = _ParentService.GetUserContext(); IVsUserContext pSubCtx = GetUserContext(); if ((pSubCtx != null) && (userContext != null)) { NativeMethods.ThrowOnFailure(userContext.AddSubcontext(pSubCtx, (int)vsusercontextpriority, out _Cookie)); } } } }