i would like to know if there is a way to work with Events in a generic way.
Firty My Class inherit EventArgs
public class DeviceMessage : EventArgs
{
public Devices devices;
public DeviceMessage(Devices devices)
{
this.devices = devices;
}
}
My Class Events
public static class CommunicationEvent
{
public static event EventHandler<DeviceMessage> SendWeb;
public static void SendMessageToWeb(DeviceMessage arg)
{
if (SendWeb != null)
SendWeb(null, arg);
}
}
the way it is implemented is functional, because where I call the event I pass "DeviceMessage", but what I need is for the event to be generic, I can pass other classes "TankMessage", "MonitorMessage".
Not Working -
public static event EventHandler<TEventArgs> SendWeb;