D
Davor Dundovic
I'm developing one small "windows application" in C# (Visual Studio
2005) and I have a couple of questions ...
Startup form creates an instance of one of my classes. That instance
creates a new thread which has an endless loop.
1.
If I just close the form (mouse click on "X" for instance), process is
left hanging.
Why doesn't it get collected by garbage collector ?
2.
If I execute Thread.Abort() and then close the form - same thing
happens.
Why doesn't it get collected by garbage collector ?
3.
If I execute Thread.Abort() and Thread.Join() and then close the form
- everything is OK. No orphan processes are left hanging.
So I made destructor in my class that does exactly this.
If I just close the form, the destructor in my class doesn't get
called.
Why ?
4.
If I execute Thread.Abort() and Thread.Join() and then attempt to
close the form, destructor gets called ?!?
Why didn't it got called in section 3. ?
I hope someone will have good will and knowledge to answer my
questions. ;-)
Regards, Dundo.
2005) and I have a couple of questions ...
Startup form creates an instance of one of my classes. That instance
creates a new thread which has an endless loop.
1.
If I just close the form (mouse click on "X" for instance), process is
left hanging.
Why doesn't it get collected by garbage collector ?
2.
If I execute Thread.Abort() and then close the form - same thing
happens.
Why doesn't it get collected by garbage collector ?
3.
If I execute Thread.Abort() and Thread.Join() and then close the form
- everything is OK. No orphan processes are left hanging.
So I made destructor in my class that does exactly this.
If I just close the form, the destructor in my class doesn't get
called.
Why ?
4.
If I execute Thread.Abort() and Thread.Join() and then attempt to
close the form, destructor gets called ?!?
Why didn't it got called in section 3. ?
I hope someone will have good will and knowledge to answer my
questions. ;-)
Regards, Dundo.