J
Jerry Nixon
I hope this is easy,
First, I simply must not override MyMethod as shown in the sample code
- that is an unbreakable requirement. The purpose of the event is to
allow me to extend MyMethod inside the derived class, within MyMethod's
transaction and without overloading it.
The event subscription in the base is because I get a null exception
without it; I don't want to subscribe to it in the base. The event
handler in the base is because I cannot subscribe to it in the base
without the handler present.
Thank you in advance, Jerry
First, I simply must not override MyMethod as shown in the sample code
- that is an unbreakable requirement. The purpose of the event is to
allow me to extend MyMethod inside the derived class, within MyMethod's
transaction and without overloading it.
The event subscription in the base is because I get a null exception
without it; I don't want to subscribe to it in the base. The event
handler in the base is because I cannot subscribe to it in the base
without the handler present.
Thank you in advance, Jerry
Code:
class abstract MyBase
{
public delegate void MyDelegate(System.EventArgs args);
public static event MyDelegate MyEvent;
static MyBase()
{
MyEvent += MyBaseHander;
}
static void MyMethod()
{
// transaction.begin
MyEvent(new System.EventArgs());
// transaction.commit
}
static void MyBaseHander(System.EventArgs args)
{
// This executes just fine
}
}
class MyDerived : MyBase
{
static MyDerived()
{
MyEvent += MyDerivedHandler;
}
static void MyDerivedHandler(System.EventArgs args)
{
// This does not execute!?
}
}