I have an Event that is triggered by a COM Server up to many thousands times per seconds, it provides realtime price information from exchanges. In my code I can access this Event (C#):
private static void COMDataStream_Price(int SymbolNr, float Price, float Volume, DateTime Time)
{ // my code goes here }
I want to process the incoming data as fast as possible, because I realized that when it is very busy at exchanges, the frequency of the Events are even higher and sometime the Stream seems to be stuck and no Events are then triggered anymore.
So what was my Idea? I wanted to use a ConcurrentQueue to queue the data and in parallel have several Workerthreads running which dequeue the items to process them.
But now I'm somehow stuck because I can not queue the data (which consists of the most important values int SymbolNr, float Price and DateTime Time) at once into the ConcurrentQueue without wrapping them into a Instance of a (generic) Class. Because this approach seems to me very time consuming, we are talking about instantiating maybe up to 100.000 objects per second.
Am I right? What is the best performant approach to deal with this situation?