Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

VB.Net remove from List

In my code below

In the "Else"
For each row if it makes it to the Else
Remove that row from the List

Dim mtList As New List(Of Threading.Thread)

    Private Sub getThreads()
        Dim objThread As System.Threading.Thread
        Dim i As Integer = 1
        For Each objThread In mtList
            If objThread.ThreadState.ToString() <> "Stopped" And Not objThread.Name.Contains("1111111111") Then
                Dim tr As String = objThread.Name.ToString.Replace("]", "").Replace("[", "")
                FileWriteline("C:\temp\threads.txt", "Thread(" + CStr(i) + ") " + "|" + tr.Substring(tr.Length - 10) + "|" + objThread.ThreadState.ToString() + ControlChars.Cr)
                i = i + 1
            Else
                'Remove from List
            End If
        Next
        FileWriteline("C:\temp\threads.txt", "Rows: " & CStr(mtList.Count))
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

I did  have to write a reverse for loop instead of foreach