BladeLogan wrote:
I will have other threads and if I would code the whole timer process it would be a lot more code, I'm just trying to do it as profficient as possible.
You did not answer about the timer use (this is not a separate process, but the thread can be separate).
To allow your current process to terminate itself, you have to terminate each of your other threads. It can be done in different ways; you can let threads exit by themselves, using some logic and inter-thread communications, or
Abort
them (aborting needs care and clear understanding of what you are doing; this is not a trivial thing).
(By the way, one type of timers, System.Windows.Forms.Timer
always calls event handlers in the current UI thread and is the easiest to use, in this respect, but if you need any behavior which is supposed to look like more or less periodic, this type is totally unsuitable, due to its prohibitively low timing accuracy. It can be used for implementing some kinds of timeouts, in cases where accuracy is not critical at all.)Alternatively, you can make all additional thread background threads, then the runtime will terminate them, but, in most cases, I don't advise it, because then you cannot make termination of such thread controllable. In certain situations, using background thread is acceptable though; please see:
Thread.IsBackground Property (System.Threading).
I would be very careful with timers. In so many questions related to timers asked on CodeProject, I could see very few cases when using timers was reasonable, in absolute majority of cases, the use of them was misconception. This is the point which could give you the most of trouble.
—SA