I donβt have an answer yet, but I have what I think is a little more understandable for demonstrating weirdness:
using System; delegate void MyDelegate(); public class Program { static void Main(string[] args) { var c = new MyChild(); c.DisplayOddity(); Console.ReadLine(); } } public class MyParent { public virtual void X() { Console.WriteLine("Executing MyParent.X"); } } public class MyChild : MyParent { public void DisplayOddity() { MyDelegate md = base.X; Console.WriteLine("Calling Invoke()"); md.Invoke();
This does not involve any recursive calls. As a result, the same strangeness remains:
Calling Invoke() Executing MyParent.X Calling BeginInvoke() Executing MyChild.X
(If you agree that this is a simpler option, feel free to replace the code in the original question, and I will remove it from my answer :)
Honestly, this seems like a mistake. I will dig a little more.
Jon skeet
source share