Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
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 
Orjan Westin wrote:
When reading about IDisposable, I get the impression that the consensus is that once you introduce it, everything that's even heard about it need to be made IDisposable too. Can this really be correct?
Not really. It depends on how you want to maintain lifetime of your resources. Only those who take ownership of resources should care about Dispose().

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#.
If it has nothing to dispose, you should be good with the base class implementation.


Orjan Westin wrote:

Would Model have to be IDisposable? Surely the DriverWrapper is now managed, and will be tidied away when the Model is? If not, would ModelA-C need to override Dispose even if they have no further data?
You can model it either way. If model is responsible for managing lifetime of a DriverWrapper, I'd put Dispose() to model which calls DriverMapper's Dispose(). But since model gets DriverWrapper through constructor, you would be constructing it somewhere else. In this, it'd be cleaner to model it like who creates DriverWrapper will dispose it when done.

More than that, if your DriverWrapper will be initialized when your application starts and needs to be alive till it ends, and in Dispose() all you do is reclaiming native allocated memory, then you probably shouldn't worry about dispose pattern because when the application exits, OS will reclaim all it's memory. And implementing dispose pattern would be an overkill.

Orjan Westin wrote:
Honestly, at times like this I really miss RAII
That's what using keyword tries to do. But dispose pattern is different than RAII and not sure if both can be compared. A Dispose() call with never destruct a class. All it does is to provide a mechanism to release resource before GC does it by calling Finalize(). Where in RAII, the object will be removed and memory wlll be reclaimed. In .NET there is no way to do deterministic cleanup.
Best wishes,
Navaneeth

AnswerRe: IDisposable spread Pin
BobJanova13-Feb-13 23:54
BobJanova13-Feb-13 23:54 
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 
GeneralRe: propertygrid double click events Pin
Richard MacCutchan13-Feb-13 5:38
mveRichard MacCutchan13-Feb-13 5:38 
GeneralRe: propertygrid double click events Pin
Jone Cunha13-Feb-13 7:32
professionalJone Cunha13-Feb-13 7:32 
QuestionEnevts in MVC application. Need some Help. Pin
plywoods12-Feb-13 21:09
plywoods12-Feb-13 21:09 
QuestionHow to determine whether the given geo code in within geo fence or not? Pin
Vijay Kanda12-Feb-13 20:57
Vijay Kanda12-Feb-13 20:57 
AnswerRe: How to determine whether the given geo code in within geo fence or not? Pin
Pete O'Hanlon12-Feb-13 23:13
mvePete O'Hanlon12-Feb-13 23:13 
Questioncalling a method in c++ from c# Pin
bonosa12-Feb-13 17:45
bonosa12-Feb-13 17:45 
AnswerRe: calling a method in c++ from c# Pin
N a v a n e e t h12-Feb-13 22:19
N a v a n e e t h12-Feb-13 22:19 
GeneralRe: calling a method in c++ from c# Pin
bonosa13-Feb-13 3:55
bonosa13-Feb-13 3:55 
GeneralRe: calling a method in c++ from c# Pin
N a v a n e e t h13-Feb-13 18:21
N a v a n e e t h13-Feb-13 18:21 

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.