Board index » Visual Studio » Best way to stop and restart a System.Timers.Timer
|
Flojay9
|
Best way to stop and restart a System.Timers.Timer
Visual Studio350
Hi, What is the best way to release all resources holded by the Timer (myTimer from class System.Timers.Timer)? Is it: 1- myTimer.dispose 2- myTimer.enabled = false 3- myTimer.close I want to have the timer set to nothing so I can recreate a new one, I want to do this in a second step: myTimer = New System.Timers.Timer AddHandler myTimer.Elapsed, AddressOf ListenToRequest myTimer.Interval = 100 myTimer.Enabled = True I am asking this because it seem that the timer loop a couple of time before being stopped, and raising errors by the way. This is my original code: myTimer.Dispose() myTimer = New System.Timers.Timer AddHandler tmrClientQwery.Elapsed, AddressOf ListenToRequest myTimer.Interval = 100 myTimer.Enabled = True Thank you very much - |
