Click here to Skip to main content
15,917,176 members
Home / Discussions / C#
   

C#

 
QuestionDataset Update Pin
Stefano Negro16-May-09 10:03
Stefano Negro16-May-09 10:03 
QuestionMulti-threading using AutoResetEvent [modified] Pin
steve_rm16-May-09 9:28
steve_rm16-May-09 9:28 
AnswerRe: Multi-threading using AutoResetEvent Pin
S. Senthil Kumar16-May-09 9:39
S. Senthil Kumar16-May-09 9:39 
AnswerRe: Multi-threading using AutoResetEvent Pin
steve_rm16-May-09 17:24
steve_rm16-May-09 17:24 
GeneralRe: Multi-threading using AutoResetEvent Pin
Joe Woodbury16-May-09 18:21
professionalJoe Woodbury16-May-09 18:21 
GeneralRe: Multi-threading using AutoResetEvent Pin
steve_rm16-May-09 23:53
steve_rm16-May-09 23:53 
GeneralRe: Multi-threading using AutoResetEvent Pin
S. Senthil Kumar17-May-09 1:26
S. Senthil Kumar17-May-09 1:26 
GeneralRe: Multi-threading using AutoResetEvent Pin
Daniel Grunwald17-May-09 1:30
Daniel Grunwald17-May-09 1:30 
AnswerRe: Multi-threading using AutoResetEvent Pin
Luc Pattyn16-May-09 10:00
sitebuilderLuc Pattyn16-May-09 10:00 
Questionfind file in web Pin
michaelgr116-May-09 4:17
michaelgr116-May-09 4:17 
AnswerRe: find file in web Pin
Roland Szigeti16-May-09 4:23
Roland Szigeti16-May-09 4:23 
GeneralRe: find file in web Pin
michaelgr116-May-09 4:32
michaelgr116-May-09 4:32 
GeneralRe: find file in web Pin
Roland Szigeti16-May-09 4:34
Roland Szigeti16-May-09 4:34 
GeneralRe: find file in web Pin
michaelgr116-May-09 4:36
michaelgr116-May-09 4:36 
GeneralRe: find file in web Pin
harold aptroot16-May-09 6:16
harold aptroot16-May-09 6:16 
GeneralRe: find file in web Pin
Manas Bhardwaj16-May-09 6:17
professionalManas Bhardwaj16-May-09 6:17 
GeneralRe: find file in web Pin
michaelgr116-May-09 6:35
michaelgr116-May-09 6:35 
AnswerRe: find file in web Pin
MumbleB16-May-09 6:45
MumbleB16-May-09 6:45 
GeneralRe: find file in web Pin
michaelgr116-May-09 7:09
michaelgr116-May-09 7:09 
GeneralRe: find file in web Pin
michaelgr116-May-09 8:28
michaelgr116-May-09 8:28 
AnswerRe: find file in web Pin
S. Senthil Kumar16-May-09 9:11
S. Senthil Kumar16-May-09 9:11 
QuestionC++ virtual destructor in C#? Why not? Pin
devvvy16-May-09 2:23
devvvy16-May-09 2:23 
AnswerRe: C++ virtual destructor in C#? Why not? Pin
S. Senthil Kumar16-May-09 4:45
S. Senthil Kumar16-May-09 4:45 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
devvvy16-May-09 5:37
devvvy16-May-09 5:37 
GeneralRe: C++ virtual destructor in C#? Why not? Pin
S. Senthil Kumar16-May-09 9:01
S. Senthil Kumar16-May-09 9:01 
devvvy wrote:
Just a thought, despite in IL code finalizer (or C#'s destructor) is virtual - does CLR automatically call BOTH (like in C++):
(a) ~Base
(b) ~Derived


Yes, the base class finalizer will be invoked at the end of the derived class finalizer.


devvvy wrote:

Also don't you think it's more clean and reliable if C# Disposable gets invoked the same way C++ virtual destructor does? That BOTH Base/Derived are invoked?


I agree, it is cleaner. To explain why it is not done right now,

interface ISome
{
   void DoSome();
}

class BaseSome : ISome
{
   public virtual void DoSome() { Console.WriteLine("BaseSome"); }
}

class DerivedSome : BaseSome
{
   public override void DoSome() { Console.WriteLine("DerivedSome"); }
}

void Main()
{
   ISome some = new DerivedSome();
   some.DoSome();
}


Would you expect DoSome to chain i.e. print "DerivedSome" and "BaseSome"? You wouldn't, because you've overrode the method to have custom behavior. Calling the base class method might be useful in some situations, but there's no way the language can force all overridden implementations to call the base implementation at the end/beginning.

Because disposal is exposed through IDisposable, an interface like ISome, what you expect cannot happen unless the C# compiler treats the interface as a special case.

The reason why it doesn't have to do this for finalizers is that the finalizer is declared in System.Object, which every .NET type must derive from.

Regards
Senthil [MVP - Visual C#]
_____________________________
My Home Page |My Blog | My Articles | My Flickr | WinMacro

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.