I have created and started a thread timer in the application event sub "myapplication_startup" using the following code:
Dim TheThreadTimerStateObj As New ThreadTimerStateObj Dim TimerDelegate As New Threading.TimerCallback(AddressOf TheThreadTimerStateObj.ThreadTimerTask)TheThreadTimerStateObj.TimerReference =
New System.Threading.Timer(TimerDelegate, TheThreadTimerStateObj, 5000, 5000)And here is the object definition:
Public
Class ThreadTimerStateObj Public TimerReference As System.Threading.Timer<irrelevant code not pictured>
Public Sub ThreadTimerTask(ByVal ThreadTimerStateObj As Object) <...bleah bleah...> End SubEnd
Class
I stored a reference to the new System.Threading.Timer object (created by the 3rd line of code) within my ThreadTimerStateObj class so that the garbage collector wouldn't destroy the new timer after I exited the sub, and it seems to be working.
THE QUESTION: Must I also save a reference somewhere to the new ThreadTimerStateObj object "TheThreadTimerStateObj" to prevent it from eventually being destroyed, or is a reference already being saved internally somehow when TheThreadTimerStateObj.ThreadTimerTask is passed as an argument to create the new System.Threading.Timer