C++, MFC Event Driven Multithreading Performance and Com+
Posted on 2004-10-05
I have written a Visual C++ (MFC) application that responds to an Active X event that reads data from a serial port. This data is received from an RF base station through the port which connects to multiple RF units. When the event is fired I process the data and return a reponse back through the port to the base station and to an RF unit. Each event is processed in sequence before the next event. Some events require more processing time than others (such as database lookups). Since there may be data ready on the port while a current event is being processed, I tried a multithreading approach (AfxBeginThread) to speed up processing if one event takes longer than another. This approach is working but when two (or more) threads process at the same time the performance is degraded.
I have considered writing a Com+ application to handle the events simultaneously, but I'm not sure that the multithreading or marshaling will be any better. In a nut shell I need the events to be handled like a mini-server that can process requests in tandem and still provide better performance than the current sequential event handling that I am using. For compatability I need to stick with Visual C++ (6.0) and MFC and time is critical.
I would appreciate any input on the best performance options available. Is the Com+ approach viable? Does each call of the Com+ component within the main application create a separate process?