共用方式為


LifetimeInformation.HasBeenDeleted 屬性

取得值,指出記憶體回收行程是否尚未捨棄已遭到刪除的物件。

命名空間:  EnvDTE80
組件:  EnvDTE80 (在 EnvDTE80.dll 中)

語法

'宣告
ReadOnly Property HasBeenDeleted As Boolean
bool HasBeenDeleted { get; }
property bool HasBeenDeleted {
    bool get ();
}
abstract HasBeenDeleted : bool with get
function get HasBeenDeleted () : boolean

屬性值

類型:Boolean
如果在記憶體回收行程後方的物件已遭到刪除則為 true,否則為 false。

備註

這個屬性是用來表示您擁有某個物件的參考,但是這個物件已不再有效,並且所有對這個物件進行的呼叫都會失敗。

範例

Sub TaskItemObjectLifetime(ByVal DTE As DTE2)
    Dim tskItem As TaskItem
    Dim tskItems As EnvDTE.TaskItems
    Dim lifetimeInfo As LifetimeInformation

    tskItems = DTE.ToolWindows.TaskList.TaskItems
    tskItem = tskItems.Add("Category", "SubCategory", "Description", _
      vsTaskPriority.vsTaskPriorityLow, EnvDTE.vsTaskIcon. _
      vsTaskIconUser, True, "", -1, True, True)
    tskItems.ForceItemsToTaskList()
    lifetimeInfo = tskItem
    MsgBox("Has task item been deleted? " & _
      lifetimeInfo.HasBeenDeleted.ToString)
    tskItem.Delete()
    MsgBox("Has task item been deleted? " & _
      lifetimeInfo.HasBeenDeleted.ToString)
End Sub
public void TaskItemObjectLifetime(DTE2 DTE)
{
    TaskItem tskItem;
    EnvDTE.TaskItems tskItems;
    LifetimeInformation lifetimeInfo;

    tskItems = DTE.ToolWindows.TaskList.TaskItems;
    tskItem = tskItems.Add("Category", "SubCategory", "Description", 
      vsTaskPriority.vsTaskPriorityLow, 
      EnvDTE.vsTaskIcon.vsTaskIconUser, true, "", -1, true, true);
    tskItems.ForceItemsToTaskList();
    lifetimeInfo = (LifetimeInformation)tskItem;
    MessageBox.Show("Has task item been deleted? " + 
      lifetimeInfo.HasBeenDeleted);
    tskItem.Delete();
    MessageBox.Show("Has task item been deleted? " +  
      lifetimeInfo.HasBeenDeleted);
}

.NET Framework 安全性

請參閱

參考

LifetimeInformation 介面

EnvDTE80 命名空間

其他資源

如何:編譯和執行 Automation 物件模型程式碼範例