Is there a reason that you're not using threads from the Thread Pool, perhaps 
by using the BackgroundWorker component (maybe more than one of them) to get 
things done?  It sounds like your threads are mostly waiting.  You could 
perhaps use a Timer component owned by the main form to queue up the 
activity(ies) to be done every-so-often.  That would simplify things like 
shutting down, as you could just turn the timer off and exit when there's no 
background work still going on.

What's the intent of what you're doing?  (Sometimes knowing that can point to 
other ways of doing things.  For example, if you're trying to react to the 
presence of a new file in a particular directory, there's a FileSystemWatcher 
class that can help.)  Are you on VS05/.Net 2, or on VS03?

At 06:58 AM 5/17/2006, Alexander Herrmann wrote
>Hi there,
>
>I need an advice for threading with windows.forms aso.
>I got a little Windows.Forms application, after starting it I have to
>instantiate some other classes (no forms classes) that have to run in a
>seperate thread and - the most important thing: this classes have to be kept
>alive as they are using some timers that frequently check some data from the
>operating system. The problem is when I create a new thread and set a method
>as starting point that instantiates this classes aso the thread is closed
>after the instantiating, there is no reaction on the event handlers of the
>instantiates classes. How can I keep the Thread alive?
>
>I tried it like this:
>
>Thread t = new Thread(new ThreadStart(ThreadJob));
>t.IsBackground = true;
>t.Start();
>
>...
>
>void ThreadStart()
>{
>Job1 j1 = new Job1();
>j1.StartWorking();
>...
>}
>
>Thanks in advance!


J. Merrill / Analytical Software Corp

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to