Delegate is Null

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am experiencing a problem using an event to log to a file. The problem is
that in the second wiring, the following is always null - never the case in
the first wiring

protected void OnLog(string message)
{
if(Log!=null) Log(message);
}

In my static main I have two delegate wires to the same event

qbthread.Log +=new Namespace.....QBThread.LogHandler(log.Add);
dba.Log +=new Namespace....Console.DB.DatabaseFactory.LogHandler(log.Add);

In the qbathread the reference is not null and is working, but in the dba
the reference is always null.

Both the qbathread and the dba thread have this code in their class:
#region Wire to the Logger Section

# region Delegates
public delegate void LogHandler(string message);
#endregion

#region Events
public event LogHandler Log;
#endregion

# region Protected Methods
protected void OnLog(string message)
{
if(Log!=null) Log(message);
}
#endregion

#endregion

And the log.add call is a reference to a function that writes to a log file.

Any help is appreciated, I can send more code if this doesnt make any sense!
Thanks
 
Back
Top