Partager via


LifetimeInformation.HasBeenDeleted Property

Definition

Gets a value indicating whether whether an object has been deleted but not yet discarded by the garbage collector.

public:
 property bool HasBeenDeleted { bool get(); };
public:
 property bool HasBeenDeleted { bool get(); };
[System.Runtime.InteropServices.DispId(1)]
public bool HasBeenDeleted { [System.Runtime.InteropServices.DispId(1)] get; }
[<System.Runtime.InteropServices.DispId(1)>]
[<get: System.Runtime.InteropServices.DispId(1)>]
member this.HasBeenDeleted : bool
Public ReadOnly Property HasBeenDeleted As Boolean

Property Value

true if the object behind it has been deleted; otherwise, false.

Attributes

Examples

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);  
}  

Remarks

This property is used to signify that you have a reference to an object that is no longer valid and any calls to the object should fail.

Applies to