Hello,
VS 2005
I have the following code below and I would like to remove an object from the list.
The error message i am getting is: "Collection was modified; enumeration operation may not execute"
The way I am filling
Many thanks for any help,
Steve
VS 2005
I have the following code below and I would like to remove an object from the list.
Code:
For Each timerToStop As Windows.Forms.Timer In emailTimerArray
If (timerToStop.Tag = callID) Then 'Stop this timer
timerToStop.Stop()
timerToStop.Enabled = False
emailTimerArray.Remove(timerToStop) 'Error
End If
Next
The error message i am getting is: "Collection was modified; enumeration operation may not execute"
Code:
Dim emailTimerArray As New List(Of Windows.Forms.Timer)
The way I am filling
Code:
emailTimer = New System.Windows.Forms.Timer
emailTimer.Interval = 25000
emailTimer.Enabled = True
emailTimer.Tag = e.CallID
emailTimerArray.Add(emailTimer)
Many thanks for any help,
Steve