LifetimeInformation.HasBeenDeleted 属性

获取一个值,该值指示对象是否已被删除但尚未被垃圾回收器丢弃。

命名空间:  EnvDTE80
程序集:  EnvDTE80(在 EnvDTE80.dll 中)

语法

声明
ReadOnly Property HasBeenDeleted As Boolean
bool HasBeenDeleted { get; }
property bool HasBeenDeleted {
    bool get ();
}
abstract HasBeenDeleted : bool
function get HasBeenDeleted () : boolean

属性值

类型:System.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 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例