The parser has an event (DataReceived) that no-one is subscribed to. The only thing that subscribes to that event is the DataReceivedEventSubscriber, but it subscribes to the event of an instance of CurrentDataDataRespParser that is internal to itself, so the only time that event is going to fire is if the methods are called on that object inside the subscriber.
You need something more like this;
public class CurrentDataDataRespParser
{
public event EventHandler<byte[]> DataReceived;
public CurrentDataDataRespParser()
{
}
public int Parse(byte[] pBuffer)
{
onDataReceived(pBuffer);
return pBuffer.Count();
}
public virtual void onDataReceived(byte[] pBuffer)
{
DataReceived?.Invoke(this, pBuffer);
}
}
public class DataReceivedEventSubscriber
{
public void DataReceived_PerformOperation(Object sender, byte[] pBuffer)
{
Console.WriteLine("Event raised,inside event handling method");
}
}
calling code;
CurrentDataDataRespParser client = new CurrentDataDataRespParser();
DataReceivedEventSubscriber sub = new DataReceivedEventSubscriber();
client.DataReceived += sub.DataReceived_PerformOperation;
client.Parse(Encoding.ASCII.GetBytes("Hello"));
That makes the method in your subscriber object subscribe to the event exposed by the parser object.