Click here to Skip to main content
15,910,787 members
Home / Discussions / C#
   

C#

 
GeneralRe: ShowDialog from seperate thread Pin
lgelliott17-Apr-08 7:18
lgelliott17-Apr-08 7:18 
Generaldispose wrapped resource Pin
George_George15-Apr-08 4:46
George_George15-Apr-08 4:46 
GeneralRe: dispose wrapped resource Pin
Simon P Stevens15-Apr-08 5:03
Simon P Stevens15-Apr-08 5:03 
GeneralRe: dispose wrapped resource Pin
George_George15-Apr-08 5:07
George_George15-Apr-08 5:07 
GeneralRe: dispose wrapped resource Pin
Simon P Stevens15-Apr-08 7:34
Simon P Stevens15-Apr-08 7:34 
GeneralRe: dispose wrapped resource Pin
George_George15-Apr-08 23:25
George_George15-Apr-08 23:25 
GeneralRe: dispose wrapped resource Pin
Simon P Stevens16-Apr-08 1:21
Simon P Stevens16-Apr-08 1:21 
GeneralRe: dispose wrapped resource Pin
George_George16-Apr-08 1:55
George_George16-Apr-08 1:55 
Thanks Simon,


I think there is another solution, which is only the most derived class implements Finalize method, and in the Finalize method, call Dispose method, in the Dispose method, call base class's Dispose method. As mentioned here,

http://msdn2.microsoft.com/en-us/library/b1yfkh5e(VS.80).aspx[^]

--------------------
Implement the dispose design pattern on a base type that commonly has derived types that hold onto resources, even if the base type does not. If the base type has a Close method, often this indicates the need to implement Dispose. In such cases, do not implement a Finalize method on the base type. Finalize should be implemented in any derived types that introduce resources that require cleanup.
--------------------

Do you think it will achieve the same effect as your method below?

--------------------
No, the derived class should not have a finalizer. Only the base class should. The derived class should override the Dispose(bool isDisposing) method to clean up the derived classes resources. The base classes finaliser will call the derived classes overridden dispose(false) method (because it's a virtual method) which will then clean up your derived classes native resources.
--------------------


regards,
George
GeneralRe: dispose wrapped resource Pin
Simon P Stevens16-Apr-08 4:18
Simon P Stevens16-Apr-08 4:18 
GeneralRe: dispose wrapped resource Pin
George_George16-Apr-08 4:23
George_George16-Apr-08 4:23 
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 
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 

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.