Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using IDisposable
Message
De
21/11/2008 17:20:27
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
21/11/2008 17:03:01
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Application:
Desktop
Divers
Thread ID:
01363570
Message ID:
01363590
Vues:
10
>Yikes. This doesn't sound good. What are you doing that you need major garbage collection? Do you have a link for this quote?
>
>>I don't know Craig, I am having one of those days when I don't know what is right anymore. I just finished reading an article by a respected source that says and I quote
>>"The most important point to remember if you supply a destructor is that you cannot predict when it will be called - it will only be executed when the garbage collector runs and removes it from memory. It is for this reason that if you have any expensive unmanaged resources to release when your class is destroyed, it is preferable to dispose of them in a Close() or Dispose() method that can be called explicitly by the user of the class. In actual fact, we can never guarantee that a destructor will ever be called since we can tell the garbage collector NOT to call an object's destructor with the SuppressFinalize method of the System.GC class.
>>Does this insure my method would be called?

This goes back to my file based queue. If I save a record and then can't delete it right away for some reason it causes a constraint exception if it tries to get saved again. From there on the queue is blocked because of a file that is already saved and didn't get deleted. Soo.. What I am doing for right now is putting the files that are saved but not deleted into a List collection. The next time I delete files I attempt to also delete the files in this list. When the class is shut down and the List object goes away if there are still files in the list then I need to persist this list. I am serializing that list to an xml and deserializing it on startup. This serialization needs to happen or the list of files that have already been saved and not deleted is lost. Unfortunately my means of determining the root cause of constraint exception is not good or I would just wipe the file out when that occurs. It is certainly possible for me to pre-test each file to determine if it already exists in the data before trying to save it, but that will be expensive in performance. This data is being saved via WCF to a sql server on a non reliable connection.

The quote came from CodeGuru.com and the author was Jay Miller. I would have to search again to find which article it was. Sorry I should have kept the link and pasted it.
Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform