private void Init() { // Create threads to handle the messages _clientThread = new Thread(ProcessClientMessages); _serverThread = new Thread(ProcessServerMessaages); // Create the suspend/resume mutexes, initially lock them _clientMutex = new Mutex(); _serverMutex = new Mutex(); _clientMutex.WaitOne(); _serverMutex.WaitOne(); // Start the running the threads _serverThread.Start(); _clientThread.Start(); // The encoding class controls which thread runs next // by inspecting the stream content _enc = new TWSPlaybackPlayerEncoding(_logStream, _clientMutex, _serverMutex); // The "local" loop-back server provides a "reversed engineered" view into // what API the client was using and how exactly _loopbackServer = new TWSLoopbackServer(_logStream, _enc); _loopbackServer.Login += LoopbackServer_Login; _loopbackServer.MarketDataRequest += LoopbackServer_MarketDataRequest; _loopbackServer.MarketDepthCancel += LoopbackServer_MarketDepthCancel; }