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

C#

 
QuestionGridView FindControl LINQ Update Pin
RickSharp13-Feb-13 12:34
RickSharp13-Feb-13 12:34 
AnswerRe: GridView FindControl LINQ Update Pin
RickSharp13-Feb-13 12:43
RickSharp13-Feb-13 12:43 
AnswerRe: GridView FindControl LINQ Update Pin
Richard MacCutchan13-Feb-13 22:29
mveRichard MacCutchan13-Feb-13 22:29 
GeneralRe: GridView FindControl LINQ Update Pin
RickSharp14-Feb-13 6:43
RickSharp14-Feb-13 6:43 
GeneralRe: GridView FindControl LINQ Update Pin
Richard MacCutchan14-Feb-13 6:58
mveRichard MacCutchan14-Feb-13 6:58 
GeneralRe: GridView FindControl LINQ Update Pin
RickSharp14-Feb-13 10:31
RickSharp14-Feb-13 10:31 
GeneralRe: GridView FindControl LINQ Update Pin
RickSharp14-Feb-13 13:28
RickSharp14-Feb-13 13:28 
QuestionC# Cannot access a disposed object Pin
classy_dog13-Feb-13 8:06
classy_dog13-Feb-13 8:06 
AnswerRe: C# Cannot access a disposed object Pin
Pete O'Hanlon13-Feb-13 8:13
mvePete O'Hanlon13-Feb-13 8:13 
AnswerRe: C# Cannot access a disposed object Pin
jschell13-Feb-13 10:15
jschell13-Feb-13 10:15 
QuestionIDisposable spread Pin
Orjan Westin13-Feb-13 2:45
professionalOrjan Westin13-Feb-13 2:45 
AnswerRe: IDisposable spread Pin
DaveyM6913-Feb-13 4:52
professionalDaveyM6913-Feb-13 4:52 
AnswerRe: IDisposable spread Pin
Keith Barrow13-Feb-13 5:13
professionalKeith Barrow13-Feb-13 5:13 
GeneralRe: IDisposable spread Pin
PIEBALDconsult13-Feb-13 17:46
mvePIEBALDconsult13-Feb-13 17:46 
GeneralRe: IDisposable spread Pin
N a v a n e e t h13-Feb-13 18:59
N a v a n e e t h13-Feb-13 18:59 
GeneralRe: IDisposable spread Pin
Orjan Westin13-Feb-13 22:33
professionalOrjan Westin13-Feb-13 22:33 
AnswerRe: IDisposable spread Pin
N a v a n e e t h13-Feb-13 18:56
N a v a n e e t h13-Feb-13 18:56 
AnswerRe: IDisposable spread Pin
BobJanova13-Feb-13 23:54
BobJanova13-Feb-13 23:54 
Orjan Westin wrote:
Now, the derived classes are already IDisposable from DriverWrapper, but if they only hold delegates, which aren't IDisposable themselves, is there any need to override Dispose(bool) in these? I think not, but I'm no expert on C#.

No. As you say they already implement IDisposable through inheritance, and if they don't specify any expensive resources that you need to clean up before the GC gets around to collecting your object, then you don't need to specify additional dispose behaviour.

Would Model have to be IDisposable?

If you want it to be cleaned up before the GC notices it, then yes. And since it's wrapping a class which you already decided should be disposable, then so should the wrapper, and its Dispose should call the driver's Dispose. These two sets of classes seem so closely related that I wonder if you need to have two sets of classes at all, though.

If not, would ModelA-C need to override Dispose even if they have no further data?

No (see first point).

You need to implement IDisposable if you are allocating resources that you want to have guaranteed return at a known time on, but you don't have sufficient control over the context to explicitly call a close method to release them. It's also convenient to implement it when you do have that context, but you want to use the class in a using(x) block, or if you might forget you're supposed to call a close method (as Dispose will get called in GC cleanup too).

You don't need to implement it if the resources you're allocating in a class are so small and unlimited in number available that you don't mind if they don't get collected for a while. That applies to most managed objects, unless they're really huge and there's a memory impact (though the GC will notice this and run a collection sooner than otherwise), and to unmanaged resources that aren't limited (e.g. non-locking file handles, sockets, bitmap handles etc). The other case is that if you know you need a resource for the entire lifetime of your process you don't need to implement IDisposable either, as the one time that finalisers are guaranteed to be called is in process shutdown (assuming it's a clean shutdown), and even if it doesn't get run, the OS will clean up after you.
Questionpropertygrid double click events Pin
Jone Cunha13-Feb-13 0:56
professionalJone Cunha13-Feb-13 0:56 
AnswerRe: propertygrid double click events Pin
Richard MacCutchan13-Feb-13 1:14
mveRichard MacCutchan13-Feb-13 1:14 
GeneralRe: propertygrid double click events Pin
Jone Cunha13-Feb-13 1:24
professionalJone Cunha13-Feb-13 1:24 
GeneralRe: propertygrid double click events Pin
Richard MacCutchan13-Feb-13 1:44
mveRichard MacCutchan13-Feb-13 1:44 
GeneralRe: propertygrid double click events Pin
Jone Cunha13-Feb-13 1:53
professionalJone Cunha13-Feb-13 1:53 
GeneralRe: propertygrid double click events Pin
Richard MacCutchan13-Feb-13 3:16
mveRichard MacCutchan13-Feb-13 3:16 
GeneralRe: propertygrid double click events Pin
Jone Cunha13-Feb-13 4:45
professionalJone Cunha13-Feb-13 4:45 

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.