-
January 23rd, 2008, 03:52 AM
#9
Dear Dario,
Thanks for your help, I tried follow by your instruction, but after every 5 second when the data file changed, the Data Adapter didn't receive all data and detect the changed data in order to send them to Lightstreamer. i don't know what are my fault? Can u help me?
Here my changed :
--- "ExternalFeed.cs" file, ExternalFeedSimulator class ----
constructor :
---
private IDictionary _stockGenerators;
public ExternalFeedSimulator {
//create an IDictionary
_stockGenerators= new Hashtable();
ISecurityStructReader reader;
reader = new ReadSecurityStruct("C:\\TEMP\\BACKUP14\\SECURITY.D AT");
nStock = 0;
if (reader.Open())
{
arr = reader.Read();
nStock = arr.Count;
m_stockSymbol = new string[nStock];
m_openprices = new double[nStock];
m_stockNames = new string[nStock];
...
for (int i=0; i< nStock ;i++)
{
Struct_Security item = (Struct_Security)arr[i];
m_openprices[i]= item.OpenPrice;
...
}
}
reader.Close();
}
public void Start()
{
//Start a new thread
lock (this)
{
if (_snapshotSender != null) return;
_snapshotSender = new Thread(new ThreadStart(Run));
_snapshotSender.Start();
}
}
public void Run()
{
do
{
//every 5 seconds
int waitMillis= ComputeNextWaitTime();
Thread.Sleep(waitMillis);
//read the file ReadBinaryFile();
//for each stock for (int i=0; i<= nStock; i++)
{
//create an IDictionary to store all field name/value pairs associate the IDictionary to the stock name in _snaps
string itemName= "item" + (i + 1);
ExternalFeedProducer myProducer = new ExternalFeedProducer(itemName, m_openprices[i], m_refprices[i], m_minprices[i], m_maxprices[i], m_stockSymbol[i], m_stockNames[i], m_ceiling[i], m_floor[i], m_bid1[i], m_bid2[i], m_bid3[i], m_bid1vol[i], m_bid2vol[i], m_bid3vol[i], m_ask1[i], m_ask2[i], m_ask3[i], m_ask1vol[1], m_ask2vol[i], m_ask3vol[i], m_last[i], m_lastVal[i], m_lastVol[i], m_projectOpen[i]);
_stockGenerators[itemName]= myProducer;
//call onEvent on the listener and send the IDictionary
_listener.OnEvent(myProducer.GetItemName(), myProducer.GetCurrentValues(true), true);
}
} while (true);
}
public int ComputeNextWaitTime()
{
lock (this)
{
return 5000;
}
}
public void SendCurrentValues(string itemName)
{
//get the IDictionary associated to the requested item name in _snap
ExternalFeedProducer myProducer= (ExternalFeedProducer) _stockGenerators[itemName];
//call onEvent on the listener with an empty IDictionary, if not found.
if (myProducer == null) return;
//if found, call onEvent on the listener and send the IDictionary
_listener.OnEvent(myProducer.GetItemName(), myProducer.GetCurrentValues(true), 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:37 PM.
Bookmarks