C
Claire
The following is an extract from my base protocol class. It worked fine
until I changed my code so that each type of comms wll be handled by its own
protocol class.
I created a single Protocol abstract class and a couple of derived classes.
The delegate and event are declared in the base class as below.
// Base abstract Protocol class.
public abstract class Protocol : object
{
public delegate void ReceivedTourHandler(object sender,
BaseConverter.FileEventArgs e);
public event ReceivedTourHandler DoReceiveTourEvent;
}
// Derived class
public class DI225Protocol : Protocol
{
public MyFunc(void)
{
if (DoReceiveTourEvent != null) <<<< Error here "C The event
'Protocol.DoReceiveTourEvent' can only appear on the left hand side of +=
or -="
{
foo;
}
}
}
I'm also receiving a warning on the "public event ReceivedTourEvent "
declaration line that
"Protocol.cs(27): The event 'Protocol.DoReceiveTourEvent' is never used"
But in my CommunicationHandler object, this value is being used and is set
as follows
m_RapiDriver = new PPC_Driver();
m_RapiDriver.protocol.DoReceiveTourEvent += new
Protocol.ReceivedTourHandler(ReceiveHandler);
Any ideas what I'm doing wrong please?
Claire
until I changed my code so that each type of comms wll be handled by its own
protocol class.
I created a single Protocol abstract class and a couple of derived classes.
The delegate and event are declared in the base class as below.
// Base abstract Protocol class.
public abstract class Protocol : object
{
public delegate void ReceivedTourHandler(object sender,
BaseConverter.FileEventArgs e);
public event ReceivedTourHandler DoReceiveTourEvent;
}
// Derived class
public class DI225Protocol : Protocol
{
public MyFunc(void)
{
if (DoReceiveTourEvent != null) <<<< Error here "C The event
'Protocol.DoReceiveTourEvent' can only appear on the left hand side of +=
or -="
{
foo;
}
}
}
I'm also receiving a warning on the "public event ReceivedTourEvent "
declaration line that
"Protocol.cs(27): The event 'Protocol.DoReceiveTourEvent' is never used"
But in my CommunicationHandler object, this value is being used and is set
as follows
m_RapiDriver = new PPC_Driver();
m_RapiDriver.protocol.DoReceiveTourEvent += new
Protocol.ReceivedTourHandler(ReceiveHandler);
Any ideas what I'm doing wrong please?
Claire