C
cider123
I have a simple Window Service that loads up a list of Folders to
monitor, along with parameters for a maintenance profile.
Every time the interval is reached, the Window Service spawns off a
Worker thread:
....
_ActiveThread = new Thread(new ThreadStart(_WorkerThread.ThreadStart));
_ActiveThread.Start();
The method for "ThreadStart" simply loads a list of files in a defined
folder, and deletes anything older than ## days.
Some of these Folders are remote sites (various relays across the U.S.
at different company locations) so the work time required to process
thousands of files in each Folder could be fast or slow depending on
bandwidth at the time of execution--hence the reason I spawn separate
threads off.
I created an ArrayList and stored the "_ActiveThread" created, and in
another routine I have on a Timer I check the "ThreadState".
When the task is finished, the ThreadState is in a "Stopped" state and
the "IsAlive" is False.
That's great I guess, but what does this mean to the system? Are
Threads in a "Stopped" state going to eventually get Garbage Collected
when the system is ready? If not, how do I gracefully terminate it? I
have a "Dispose" Interface, but that doesn't necessarily terminate the
Thread. From what I've read, Dispose is just another method that you
can call off the object even though it's an Implemented method.
I have about 10 Threads that spawn off simultaneously at the moment.
Should one cycle through the ArrayList, if in a "Stopped" state call
the "Abort()" then remove the reference and let the system eventually
GC it? Or how exactly does that work?
I'm still searching newsgroups for answers, but if anyone has anything
to offer on comments.. I'm always game to learn new things.
monitor, along with parameters for a maintenance profile.
Every time the interval is reached, the Window Service spawns off a
Worker thread:
....
_ActiveThread = new Thread(new ThreadStart(_WorkerThread.ThreadStart));
_ActiveThread.Start();
The method for "ThreadStart" simply loads a list of files in a defined
folder, and deletes anything older than ## days.
Some of these Folders are remote sites (various relays across the U.S.
at different company locations) so the work time required to process
thousands of files in each Folder could be fast or slow depending on
bandwidth at the time of execution--hence the reason I spawn separate
threads off.
I created an ArrayList and stored the "_ActiveThread" created, and in
another routine I have on a Timer I check the "ThreadState".
When the task is finished, the ThreadState is in a "Stopped" state and
the "IsAlive" is False.
That's great I guess, but what does this mean to the system? Are
Threads in a "Stopped" state going to eventually get Garbage Collected
when the system is ready? If not, how do I gracefully terminate it? I
have a "Dispose" Interface, but that doesn't necessarily terminate the
Thread. From what I've read, Dispose is just another method that you
can call off the object even though it's an Implemented method.
I have about 10 Threads that spawn off simultaneously at the moment.
Should one cycle through the ArrayList, if in a "Stopped" state call
the "Abort()" then remove the reference and let the system eventually
GC it? Or how exactly does that work?
I'm still searching newsgroups for answers, but if anyone has anything
to offer on comments.. I'm always game to learn new things.