Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Try...catch in destructor?
Message
 
À
09/09/2005 09:09:59
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01047893
Message ID:
01048053
Vues:
15
>>Where would an exception be thrown if an exception is not handled in the destructor?
>>
>>The reason I am asking is because I would like to add code to my destructor to shutdown and close a socket if the socket is not shutdown and close before the destructor is executed.
>>
>>Kind of an odd question but it is almost 5 and my brain is overloaded.
>
>Einar,
>
>An exception is not thrown in the destructor because the code is executed by the Garbage Collector and the context is undefined. You have to close the socket in another event.

Keith,
That is what I thought. Even at 5pm yesterday it did not make a lot of sense to throw an exception in the destructor. I have shutdown and closed the socket in a finally where the socket is used, but I wanted to add something extra just in case. I guess I just need to trust the finally :)

Thanks,
Einar
Semper ubi sub ubi.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform