Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using IDisposable
Message
From
22/11/2008 14:18:57
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Application:
Desktop
Miscellaneous
Thread ID:
01363570
Message ID:
01363668
Views:
10
Hi Paul,

>>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.
>
>Serialize the "files to delete" list on each timer event (or even after adding a new item to the list) - I wouldn't wait until shutdown if you're really worried about it. When you run through the list later just check to see if the file exists or not; if not, just move on.

I found a way to make sure it gets handled from the app side but my question or confusion seems to be more of a generic one with regards to using a destructor and or finalizer (Dispose). I understand how to implement IDisposable properly, but was thrown by the idea that you shouldn't call a method from there. This means one pretty much need to clean up everything within the Dispose Method which may or may not be a repeat of doing it somewhere else. Not a programming practice I typically follow. Shoot, I rarely put much in a button click handler other than a call to another method.

Thanks
Tim
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform