Another thing, what are you doing in your finalizer (or Dispose(false))? I'd be very surprised if you ever need to define a finalizer for a class in Silverlight.
From: [email protected] [mailto:[email protected]] On Behalf Of David Kean Sent: Tuesday, April 13, 2010 4:30 PM To: ozDotNet Subject: RE: Dispose surprise Do you own these classes? If so, Dispose() should be calling GC.SuppressFinalize(this) to prevent finalization. There's no point finalizing, if you have been disposed. From: [email protected] [mailto:[email protected]] On Behalf Of Greg Keogh Sent: Tuesday, April 13, 2010 4:20 PM To: 'ozDotNet' Subject: FW: Dispose surprise Folks, I just rearranged some old Silverlight code so that a WCF proxy is now wrapped in a using(...). I've got Debug.WriteLine scattered through the Disposible proxy class so I can see the short lifetime of this class as it is created and disposed. I see repeated groups of lines like this: ctor make proxy proxy call dispose(true) true=called from Dispose, false=called from ~finalizer close proxy null proxy I can see that each class instance is being constructed and disposed as I expect. However I was surprised to see these lines when the App and browser were closed. dispose(false) dispose(false) dispose(false) dispose(false) -etc- So the classes are still hanging around, but aren't being finalized by the GC until the App end. I know the classes aren't holding any important resources any more, but I was quite surprised to see them all being finalized in a bunch so late. I had this funny feeling that something was wrong, or is what you would expect? Greg
