I am trying to store an object in the generic EventArgs class, but since EventHandler has an interface, I find it difficult to accomplish this. Any way to get something like this works?
My EventArgs class:
public class PositionChangedEventArgs<T> { public PositionChangedEventArgs(byte position, T deviceArgs) { Position = position; DeviceArgs = deviceArgs; } public byte Position { get; private set; } public T DeviceArgs { get; private set; } }
Interface Used:
public interface IMoveable { event EventHandler<PositionChangedEventArgs<T>> PositionChanged; }
Class usage example:
public class SomeDevice : IMoveable { public event EventHandler<PositionChangedEventArgs<DeviceSpecificEventMessageArgs>> PositionChanged;
source share