Click here to Skip to main content
15,867,453 members
Home / Discussions / C#
   

C#

 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 9:44
professionalDaveyM6923-Oct-09 9:44 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 9:52
professionalDaveyM6923-Oct-09 9:52 
GeneralRe: Destructor peculiarity Pin
cmk23-Oct-09 5:21
cmk23-Oct-09 5:21 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 8:10
professionalDaveyM6923-Oct-09 8:10 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 9:48
professionalDaveyM6923-Oct-09 9:48 
AnswerRe: Destructor peculiarity Pin
Gideon Engelberth23-Oct-09 7:55
Gideon Engelberth23-Oct-09 7:55 
GeneralRe: Destructor peculiarity Pin
DaveyM6923-Oct-09 9:40
professionalDaveyM6923-Oct-09 9:40 
AnswerRe: Destructor peculiarity Pin
Luc Pattyn27-Oct-09 3:36
sitebuilderLuc Pattyn27-Oct-09 3:36 
Hi Dave,

First of all I'm no expert on destruction; I've read several articles about it, and find it difficult to grasp.

My initial comments on your code are:
1. I thought one wasn't supposed to write finalizers/destructors; instead one should provide a Dispose(bool) override.
2. I am pretty sure the GC does not finalize anything when an application exits; it does when things got collected, which only happens when a new need for memory cannot be solved without it;
3. The one Manager object you create sits in a static member of class Manager, so it never dies.
4. both (2) and (3) seen sufficient to say: I can't believe CloseAll() gets called automatically.
5. There is an Application.Exit event which I believe should be the key to solving your problem.

Some more thoughts:
6. The ports keep adding to your list, even when they got closed. And they may appear more than once.
7. I would avoid managers (I generally do!) and add overall port functionality to the Port class itself, using statics (as you have in Manager anyway).

In summary:
(A) I would fire your Manager and use Application.Exit to execute Port.CloseAll()
(B) I wouldn't say "I don't know why it works", my feelings are "I am surprised it would work as is".

Cheers.

Luc Pattyn

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


GeneralRe: Destructor peculiarity Pin
DaveyM6927-Oct-09 7:04
professionalDaveyM6927-Oct-09 7:04 
GeneralRe: Destructor peculiarity Pin
Luc Pattyn27-Oct-09 7:09
sitebuilderLuc Pattyn27-Oct-09 7:09 
GeneralRe: Destructor peculiarity Pin
DaveyM6927-Oct-09 10:45
professionalDaveyM6927-Oct-09 10:45 
GeneralRe: Destructor peculiarity Pin
Luc Pattyn27-Oct-09 11:17
sitebuilderLuc Pattyn27-Oct-09 11:17 
GeneralRe: Destructor progress report 1 Pin
Luc Pattyn27-Oct-09 17:20
sitebuilderLuc Pattyn27-Oct-09 17:20 
GeneralRe: Destructor progress report 1 Pin
DaveyM6928-Oct-09 8:58
professionalDaveyM6928-Oct-09 8:58 
GeneralRe: Destructor progress report 1 Pin
Luc Pattyn28-Oct-09 9:54
sitebuilderLuc Pattyn28-Oct-09 9:54 
GeneralRe: Destructor progress report 1 Pin
DaveyM6928-Oct-09 10:52
professionalDaveyM6928-Oct-09 10:52 
GeneralRe: Destructor progress report 1 Pin
DaveyM6928-Oct-09 22:19
professionalDaveyM6928-Oct-09 22:19 
GeneralRe: Destructor progress report 1 Pin
DaveyM6928-Oct-09 9:35
professionalDaveyM6928-Oct-09 9:35 
QuestionTheading problem Pin
Rick van Woudenberg23-Oct-09 0:52
Rick van Woudenberg23-Oct-09 0:52 
AnswerRe: Theading problem Pin
Not Active23-Oct-09 2:49
mentorNot Active23-Oct-09 2:49 
Questionneed some quick help thx : how can i access and open form2 from form1 menu item Pin
KIM K23-Oct-09 0:48
KIM K23-Oct-09 0:48 
AnswerRe: need some quick help thx : how can i access and open form2 from form1 menu item Pin
nagendrathecoder23-Oct-09 0:55
nagendrathecoder23-Oct-09 0:55 
AnswerRe: need some quick help thx : how can i access and open form2 from form1 menu item Pin
Rick van Woudenberg23-Oct-09 0:57
Rick van Woudenberg23-Oct-09 0:57 
Questionhow to update progressbar in Child Form from Parent Form Pin
sandy_55723-Oct-09 0:39
sandy_55723-Oct-09 0:39 
AnswerRe: how to update progressbar in Child Form from Parent Form Pin
Rick van Woudenberg23-Oct-09 1:03
Rick van Woudenberg23-Oct-09 1:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.