J
jjkboswell
I'm trying to pin down a good naming convention for the 3 things
required to implement an event.
You need:
1) a delegate
2) an event
3) an event handler
Below is my understanding of a naming convention based on the Windows
Forms events. Can someone let me know if this convention is standard,
or suitable or just plain wrong.
Cheers
Boz
delegate void DataAvailableEventHandler(string data);
class ServerClass
{
public event DataAvailableEventHandler DataAvailable;
public FireEvent()
{
if (DataAvailable != null)
{
DataAvailable("bang");
}
}
}
class ClientClass
{
public ClientClass(ServerClass server)
{
server.DataAvailable += new
DataAvailableEventHandler(ServerClass_DataAvailable);
}
private ServerClass_DataAvailable(string data)
{
Trace.WriteLine("I got some data:\n" + data);
}
}
required to implement an event.
You need:
1) a delegate
2) an event
3) an event handler
Below is my understanding of a naming convention based on the Windows
Forms events. Can someone let me know if this convention is standard,
or suitable or just plain wrong.
Cheers
Boz
delegate void DataAvailableEventHandler(string data);
class ServerClass
{
public event DataAvailableEventHandler DataAvailable;
public FireEvent()
{
if (DataAvailable != null)
{
DataAvailable("bang");
}
}
}
class ClientClass
{
public ClientClass(ServerClass server)
{
server.DataAvailable += new
DataAvailableEventHandler(ServerClass_DataAvailable);
}
private ServerClass_DataAvailable(string data)
{
Trace.WriteLine("I got some data:\n" + data);
}
}