> If I didn't want to set the 'IsBackgroud' property of the thread, I > figured I could just implement IDisposable in my class and set > Blinker.Stop=true in Dispose(). However, that didn't seem to work. > Should it have worked? How else might I ensure that the blinkerThread > is ended correctly?
Of course you can set the Stop property from Dispose, just as you can set it from every other method. (As long as setting the field is synchronized by a lock or the field is volatile.) You just need to call Dispose before the application exits. It won't be called automatically, you have to manually invoke it, for example via a C# "using" statement. Some classes have finalizers automatically calling Dispose when the GC comes to collect instances of those classes. However, this won't work in your scenario as the thread will probably keep the instance alive so that the GC can't collect it. The point is that there are two types of threads. Those which keep an application alive, just as a "main thread" does; and those which don't. The latter are called background threads. So if you want the latter's behavior, create a background thread. If you don't want a background thread, you need to make it stop explicitly. Fabian =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com