Hi Donald,
I think you should buy youself a copy of
Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects (POSA2)[
^], and
The ACE Programmer's Guide: Practical Design Patterns for Network and Systems Programming[
^]. The latter is C++ oriented, but it will show you how to build flexible and robust software.
The POSA books are considered among the most important works on software patterns, and you can think of a pattern as a proven recipe for building software that does what it's supposed to do.
ACE is a C++ library, and IMHO one of the finer examples of software engineering. ACE is an open source project lead by
Douglas C. Schmidt[
^]. Over the years several thousand developers has contributed to this framework. ACE (and TAO) shows how patterns can be used to create "real" high performance, robust and maintainable software.
Many of the POSA patterns are implemented in the .Net framework, and the books will help you decide on, and understand, which mechanisms are best suited to solve the problems you are working on.
The solution I outlined in
How to execute high volume inserts and query the table simultaneously[
^], Leverages .Net worker threads; which is, as Nishant Sivakumar mentioned, a suitable mechanism for solving your problem.
From what I can see from your code, it seems like you are working on some kind of trading system.
If it’s for real, as in money will change hands, you have a long journey ahead of you. If this is the case - I suggest you start with reading up on the
Sarbanes–Oxley Act[
^] and other legal matters.
Next thing to look at is probably the
Financial Information eXchange (FIX) Protocol[
^], a messaging standard developed specifically for the real-time electronic exchange of securities transactions. You'll find an implementation at
http://www.quickfixengine.org/[
^], it can be used with .Net.
At this point things might seem a bit overwhelming, you need some kind of data model to build upon, because the complexity of the problem is growing exponentially.
Len Silverston[
^] provides reference models with a proven track record.
Regards
Espen Harlinn