Click here to Skip to main content
15,925,723 members
Home / Discussions / C#
   

C#

 
GeneralRe: dispose wrapped resource Pin
led mike15-Apr-08 5:13
led mike15-Apr-08 5:13 
GeneralRe: dispose wrapped resource [modified] Pin
Simon P Stevens15-Apr-08 7:09
Simon P Stevens15-Apr-08 7:09 
GeneralRe: dispose wrapped resource Pin
George_George15-Apr-08 23:28
George_George15-Apr-08 23:28 
GeneralRe: dispose wrapped resource Pin
Simon P Stevens16-Apr-08 1:32
Simon P Stevens16-Apr-08 1:32 
GeneralRe: dispose wrapped resource Pin
George_George16-Apr-08 1:59
George_George16-Apr-08 1:59 
GeneralRe: dispose wrapped resource Pin
Zoltan Balazs16-Apr-08 2:41
Zoltan Balazs16-Apr-08 2:41 
GeneralRe: dispose wrapped resource Pin
George_George16-Apr-08 2:46
George_George16-Apr-08 2:46 
GeneralRe: dispose wrapped resource Pin
Zoltan Balazs15-Apr-08 7:44
Zoltan Balazs15-Apr-08 7:44 
The thing is that in .Net we have undeterministic finalization meaning that the Finalize() method will be called at an undetermined time in the future. The solution to this is to have deterministic finalization by implementing the Dispose pattern. You should have your cleanup code in Dispose() and if you implement the Finalize() method that should call on Dispose.

George_George wrote:
BTW: if the derived class manages native resource, I think it needs to have a destructor. Any comments?

No, implement the Dispose pattern and release the native resources there. Implementing a destructor is not the best solution because you don't know when the GC will finalize the object.

For more info check out this article[^]


GeneralRe: dispose wrapped resource Pin
George_George15-Apr-08 23:31
George_George15-Apr-08 23:31 
GeneralRe: dispose wrapped resource Pin
Zoltan Balazs16-Apr-08 2:39
Zoltan Balazs16-Apr-08 2:39 
GeneralRe: dispose wrapped resource Pin
George_George16-Apr-08 2:44
George_George16-Apr-08 2:44 
GeneralCoding Style Question Pin
Waleed Eissa15-Apr-08 4:40
Waleed Eissa15-Apr-08 4:40 
GeneralRe: Coding Style Question Pin
led mike15-Apr-08 4:59
led mike15-Apr-08 4:59 
GeneralRe: Coding Style Question Pin
leppie15-Apr-08 5:09
leppie15-Apr-08 5:09 
GeneralRe: Coding Style Question Pin
Waleed Eissa15-Apr-08 5:12
Waleed Eissa15-Apr-08 5:12 
GeneralRe: Coding Style Question Pin
Dan Neely15-Apr-08 5:26
Dan Neely15-Apr-08 5:26 
GeneralRe: Coding Style Question Pin
Waleed Eissa15-Apr-08 5:38
Waleed Eissa15-Apr-08 5:38 
GeneralRe: Coding Style Question Pin
Dan Neely15-Apr-08 7:00
Dan Neely15-Apr-08 7:00 
GeneralRe: Coding Style Question Pin
K.L.K15-Apr-08 8:45
K.L.K15-Apr-08 8:45 
GeneralRe: Coding Style Question Pin
led mike15-Apr-08 7:25
led mike15-Apr-08 7:25 
GeneralRe: Coding Style Question Pin
Waleed Eissa15-Apr-08 5:10
Waleed Eissa15-Apr-08 5:10 
GeneralRe: Coding Style Question Pin
leppie15-Apr-08 5:12
leppie15-Apr-08 5:12 
GeneralRe: Coding Style Question Pin
Brady Kelly15-Apr-08 5:57
Brady Kelly15-Apr-08 5:57 
GeneralRe: Coding Style Question Pin
leppie15-Apr-08 6:01
leppie15-Apr-08 6:01 
GeneralRe: Coding Style Question Pin
Brady Kelly15-Apr-08 6:16
Brady Kelly15-Apr-08 6:16 

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.