üzerinden geçersiz kılınan bir yöntem çalıştırıldığında farklı davranan Invoke() ve BeginInvoke() yöntemi, bu kodun neden böyle davrandığını söyleyebilir mi? Kod içinde gömülü olan yorumları görün…Bir delege
Burada gerçekten belirgin bir şey eksik mi?
using System;
namespace ConsoleApplication3
{
public class Program
{
static void Main(string[] args)
{
var c = new MyChild();
c.X();
Console.ReadLine();
}
}
public class MyParent
{
public virtual void X()
{
Console.WriteLine("Executing MyParent");
}
}
delegate void MyDelegate();
public class MyChild : MyParent
{
public override void X()
{
Console.WriteLine("Executing MyChild");
MyDelegate md = base.X;
// The following two calls look like they should behave the same,
// but they behave differently!
// Why does Invoke() call the base class as expected here...
md.Invoke();
// ... and yet BeginInvoke() performs a recursive call within
// this child class and not call the base class?
md.BeginInvoke(CallBack, null);
}
public void CallBack(IAsyncResult iAsyncResult)
{
return;
}
}
}
Bunu denedim, ya bir sorun olduğunu farkındaydı, ama bu gelen sorunların çok görebilirsiniz değil. Belki birisi açıklayabilir :) – leppie