2015-07-01 77 views
0

在包我試圖建立我註冊了「BeforeClosing」事件以下列方式:取消在VS擴展解決方案,關閉事件

DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE; 
dte.Events.SolutionEvents.BeforeClosing += SolutionEvents_BeforeClosing; 

和事件處理程序是這樣的:

private void SolutionEvents_BeforeClosing() 
{ 
    //Check some stuff 
    //Cancel the close operation 
} 

是否可以從事件處理程序(如e.Cancel = true;)中取消關閉解決方案?

回答

0

使用QueryCloseSolution解決方案事件 - 事件處理程序通過引用布爾變量,該變量必須設置爲true以便中止當前關閉嘗試。