// // // /// <summary> /// Here, we already have the event object (perhaps someone else created it). Before /// triggering event, we mark that we are the senders, but note, if someone else created /// it, "CustomEventCreator" could be a different object (say, the object that requested /// something from this book). /// </summary> protected void OnInstrumentChange(InstrumentChangeArgs args) { args.Sender = this; // update the sender before triggering event if (this.InstrumentChanged != null) { InstrumentChanged(this, args); } }//OnInstrumentChange()
}//LogBookState(). // // // #endregion//Private Methods #region Event Processing for Books // ***************************************************************** // **** Event Processing for Books **** // ***************************************************************** // // // // // // // **** ProcessBookEvents() **** // /// <summary> /// Once an event in the queue is determined to be a market change event, or /// any event changing the "market book" of an instrument, this method is /// called to update the market instrument books. /// Called by hub thread only. /// </summary> /// <param name="eArgList">A list of market change events.</param> protected void ProcessBookEvents(List <EventArgs> eArgList) { int updateBookID = EnterWriteLock(); // step 0.0 BringBookUpToDate(updateBookID); // Bring this book up to current date. // step 1, 2, not 3, 4, and 5. // Process new events by calling super class (since this depends on particular exchange)! InstrumentChangeArgs eventArgs = ProcessBookEventsForABook(updateBookID, eArgList); // step 3 // Finalize book that was updated. ExitWriteLock(updateBookID); m_CurrentBook = updateBookID; // Now publish book as current book! // step 6.0 //this.LogBookState(string.Empty); /* * Book aBook; * if (TryEnterReadBook(out aBook) ) * { * if (Log.BeginEntry(LogLevel.Minor, "ProcessBookEvents: ")) * { * foreach (int id in updatedInstrList) * { * Market mkt = aBook.Instruments[id]; * Log.AppendEntry(mkt.ToString()); * } * Log.EndEntry(updatedInstrList.Count > 0); * } * ExitReadBook(aBook); * } */ // Trigger events for updated instruments. if (eventArgs != null) { eventArgs.Sender = this; OnInstrumentChange(eventArgs); // step 7.0 } }//end HubEventHandler().