Hi,
I have an Generic.List(Of MyObjects) these Objects implement IDisposable and as a result I want to clean up on exit.
Regardless of how I attack this I get an error when trying this (or similar):
The error I get is
I can only assume that m_Object is only a reference to the actual Instance in the List(Of...). Does anyone know how I can clean up properly?
woogoo
I have an Generic.List(Of MyObjects) these Objects implement IDisposable and as a result I want to clean up on exit.
Regardless of how I attack this I get an error when trying this (or similar):
Code:
Protected Overrides Sub OnStop()
' Service is stopping so clean up.
Dim m_Object As MyObject = Nothing
For Each m_Object In m_Objects
m_Objects.Remove(m_Object)
m_Object.Dispose()
Next
End Sub
The error I get is
Code:
Collection was modified; enumeration operation may not execute.
woogoo