Ninja keeps crashing whenever I attempt to add the indicator to a chart. Is there anything in particular I need to know about as far as using managed threads with NT?
Example:
MyCls myCls = new MyCls();
void OnBarUpdate()
{
double high = High[0];
double low = Low[0];
double close = Close[0];
string data = string.Format("{0},{1},{2}",high,low,close);
myCls.GetData(data);
}
// my class
class MyCls
{
EventWaitHandle ewh = new AutoResetEvent(false);
object sync = new object();
Queue<string> que = new Queue<string>();
Thread t = new Thread(worker);
public MyCls()
{
t.IsBackground = true;
t.Start();
}
public void GetData(string data)
{
lock(sync)
{
que.Enqueue(data);
}
ewh.Set();
}
private void worker()
{
while(true)
{
lock(sync)
{
// get data from que.Dequeue();
// blah, blah, blah...
}
// process data....blah, blah, blah...
// after processing data block thread
ewh.WaitOne();
}
}
Comment