Problems at terminating Timers...

byle

Member
Joined
Dec 11, 2006
Messages
7
Programming Experience
1-3
Hi, I'm developing an app that uses one timer and once the timer has ticked, there's no way to close my app without seeing that exception:
VB.NET:
An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
Additional information: Collection was modified; enumeration operation may not execute.

I've tryed to comment my timer functionality, so it does not tick, and it finishes well, and the same if I try to close my application before the timer has done its first tick. But once it has done this first tick I always get the exception below when I quit the app.

To finish the app I use te following code

VB.NET:
myTimer.Stop()
myTimer.Dispose()

Me.Close()
Me.Dispose()
Application.Exit()

myTimer is a System.windows.forms.timer

Does anyone know what I'm doing wrong??
 
solved, it was not the timer. It was some files and conections opened by the timer and they were not properly closed once I wanted to exit my app
 
Back
Top