20-12-16, 07:28 PM
لو تكرمت ان تشرح لي هذا الكود و الادوات المستخدمة
Private Shared Sub __ENCAddToList(ByVal value As Object)
Dim list As List(Of WeakReference) = Form18.__ENCList
SyncLock list
If (Form18.__ENCList.Count = Form18.__ENCList.Capacity) Then
Dim index As Integer = 0
Dim num3 As Integer = (Form18.__ENCList.Count - 1)
Dim i As Integer = 0
Do While (i <= num3)
Dim reference As WeakReference = Form18.__ENCList.Item(i)
If reference.IsAlive Then
If (i <> index) Then
Form18.__ENCList.Item(index) = Form18.__ENCList.Item(i)
End If
index += 1
End If
i += 1
Loop
Form18.__ENCList.RemoveRange(index, (Form18.__ENCList.Count - index))
Form18.__ENCList.Capacity = Form18.__ENCList.Count
End If
Form18.__ENCList.Add(New WeakReference(RuntimeHelpers.GetObjectValue(value)))
End SyncLock
End Sub
Private Shared Sub __ENCAddToList(ByVal value As Object)
Dim list As List(Of WeakReference) = Form18.__ENCList
SyncLock list
If (Form18.__ENCList.Count = Form18.__ENCList.Capacity) Then
Dim index As Integer = 0
Dim num3 As Integer = (Form18.__ENCList.Count - 1)
Dim i As Integer = 0
Do While (i <= num3)
Dim reference As WeakReference = Form18.__ENCList.Item(i)
If reference.IsAlive Then
If (i <> index) Then
Form18.__ENCList.Item(index) = Form18.__ENCList.Item(i)
End If
index += 1
End If
i += 1
Loop
Form18.__ENCList.RemoveRange(index, (Form18.__ENCList.Count - index))
Form18.__ENCList.Capacity = Form18.__ENCList.Count
End If
Form18.__ENCList.Add(New WeakReference(RuntimeHelpers.GetObjectValue(value)))
End SyncLock
End Sub