-
January 17th, 2008, 04:12 AM
#1
Could you explain more about _stockGenerators, _snapshotQueue, _snapshotSender?
Could you explain more about _stockGenerators, _snapshotQueue, _snapshotSender in StockList demo code?
In "ExternalFeed.cs" file, StockListDemo code (mark by red color) :
public ExternalFeed() {
_stockGenerators= new Hashtable();
_snapshotQueue= new ArrayList();...
}
public void Start() {
if (_snapshotSender != null) return;
for (int i = 0; i < 30; i++) --> purpose of for statement? Why it loop from 1 to 30?
{
string itemName= "item" + (i + 1);
...
_stockGenerators[itemName]= myProducer;
myProducer.SetFeedListener(_listener);
myProducer.Start();
}
_snapshotSender= new Thread(new ThreadStart(Run)); --> I don't understand
_snapshotSender.Start();
}
private void Run() {
IList snapshots= new ArrayList();
do {
lock (_snapshotQueue) {
if (_snapshotQueue.Count == 0)
Monitor.Wait(_snapshotQueue);
snapshots.Clear();
while (_snapshotQueue.Count > 0) {
ExternalFeedProducer myProducer= (ExternalFeedProducer) _snapshotQueue[0];
snapshots.Add(myProducer);
_snapshotQueue.RemoveAt(0);
} }
foreach (ExternalFeedProducer myProducer in snapshots) {
_listener.OnEvent(myProducer.GetItemName(), myProducer.GetCurrentValues(true), true);
}
} while (true);
}
Similar Threads
-
By hungn in forum Adapter SDKs
Replies: 8
Last Post: May 7th, 2008, 09:53 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
All times are GMT +1. The time now is 04:22 PM.
Bookmarks