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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。