/// <param name="pkg">Owner package.</param> /// <param name="evt">Supported public events, not null.</param> public static StatusToolCommand Init(IPkg pkg, IEventLevel evt) { if(Instance != null) { return Instance; } Instance = new StatusToolCommand ( pkg, pkg.getSvc(typeof(IMenuCommandService)) as OleMenuCommandService, evt ); Instance.toolPane = Instance.initToolPane(); return Instance; }
/// <param name="pkg">Owner package.</param> /// <param name="evt">Supported public events, not null.</param> /// <param name="tool">Tool pane instance to use this instead of new when null is passed.</param> public static async Task<StatusToolCommand> InitAsync(IPkg pkg, IEventLevel evt, ToolWindowPane tool = null) { if(Instance != null) { return Instance; } // Switch to the main thread - the call to AddCommand in StatusToolCommand's constructor requires // the UI thread. await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(pkg.CancellationToken); Instance = new StatusToolCommand ( pkg, await pkg.getSvcAsync(typeof(IMenuCommandService)) as OleMenuCommandService, evt ); Instance.toolPane = await Instance.initToolPaneAsync(tool as StatusToolWindow); return Instance; }