Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Threaded Timer...
Message
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB.NET 1.1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01102225
Message ID:
01102304
Views:
20
The actual .NET Timer methods are static so once called there's no connection to your object unless it's calling a method on it for the worker method.

Anything local goes out of scope and gets cleaned up by the GC, unless there are outstanding references. So if you create the timer call some other method (not in the threaded timer class) it's gone and cleaned up. If the code calls into that class then then there's an outstanding reference to invoked class and it's not cleaned up until the method finishes. At that point the method lock releases and the delegate cleans up its reference and the GC can do its thing.

In general with Multi-threaded code the thing to understand is that once fired you disconnect. The Delegate is what holds the reference to whatever code you're executing.




>I created a class called ThreadedTimer that uses a Threading.Timer object inside it. I then used the class ThrededTimer in a subroutine on the main form of my application. My question is as follows:
>
>When the timer inside my ThreadedTimer class finishes and sets itself to Enabled = False, does garbage collection recycle the memory for this object? The reason I ask is because I create the ThreadedTimer useing a local varaible in a Command Button routine, which when the routine ends, I lose the reference to the timer. I was wondering if I should create an Array off the main form that holds reference to all the timers and then somehow destory each timer manually? The only problem is that my custom class doesn't have a destory method.
>
>I hope I didn't sound too confusing, but this has been bugging me because I don't want to inadvertantly create a memory leak.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform