d_allen
-Interested User-
Posts: 29
Joined: Nov 5, 2008
|
Posted: Jan 26, 2011 05:56 PM
Msg. 1 of 9
I'm a novice C# developer and I'm using the activeX control which fires the axIQFeedY_QuoteMessage event. I have a couple of method calls which parses the feed then inserts the results into a database but this seems to overwhelm the windows form and consumes too much of my system resources so I wanted to put the axIQFeedY_QutoeMessage event on another thread. I tried to create a thread pass the event to an anonymous delegate: ThreadStart myThreadStart = delegate() {axIQFeedY_QuoteMessage(object o, AxIQFEEDLib._DIQFeedYEvents_QuoteMessageEvent e);}
Thread myThread = new Thread(myThreadStart); myThread.Start();
I don't know where or what object to pass to the axIQFeedY_QuoteMessage or how to instantiate the axIQFeedY_QuoteMessage. Can someone please explain/show me what I'm doing wrong and the correct way to go about this.
Thanks! -Allen Edited by d_allen on Jan 26, 2011 at 05:57 PM
|
Helg37
-Interested User-
Posts: 6
Joined: Jan 4, 2011
|
Posted: Jan 27, 2011 11:31 AM
Msg. 2 of 9
Hello ! I use queue of "supplier-consumer" ConcurrentQueue. In queue data is added, and another thread takes them and work.
|
d_allen
-Interested User-
Posts: 29
Joined: Nov 5, 2008
|
Posted: Jan 27, 2011 07:13 PM
Msg. 3 of 9
thanks Helg37,
can you PLEASE show me an example of exactly what you're talking about?
-Allen Edited by d_allen on Jan 27, 2011 at 07:14 PM
|
Helg37
-Interested User-
Posts: 6
Joined: Jan 4, 2011
|
Posted: Jan 28, 2011 01:15 AM
Msg. 4 of 9
This is an example of logic that I use for processing Data Feed
using System.Threading; using System.Collections.Concurrent;
public ConcurrentQueue<Prints> prints; private EventWaitHandle wh_prints; Thread worker_print; static object locker = new object();
prints = new ConcurrentQueue<Prints>(); wh_prints = new AutoResetEvent(false);
worker_print = new Thread(WorkPrint); worker_print.Start();
Prints pq = null; GetPrint(pq); worker_print.Join(); wh_prints.Close(); worker_print.Abort();
public void GetPrint(Prints pq) { lock (locker) { prints.Enqueue(pq); wh_prints.Set(); } }
void WorkPrint() { while (true) { Prints pq = null; if (!prints.IsEmpty) { if (prints.TryDequeue(out pq)) { if (pq == null) { return; } } else continue; }
if (pq != null) { lock (locker) { ……………… } } else wh_prints.WaitOne(); } }
|
d_allen
-Interested User-
Posts: 29
Joined: Nov 5, 2008
|
Posted: Jan 28, 2011 12:51 PM
Msg. 5 of 9
Thanks Helg37! I just just wanted to say thank you for responding to my "thread" no pun intended lol! And I'm most definitely grateful for the code!!! If I have any question or need any clarification I'll ask.
take care and have a good wkEnd Helg37.
-Allen
|
d_allen
-Interested User-
Posts: 29
Joined: Nov 5, 2008
|
Posted: Jan 28, 2011 03:41 PM
Msg. 6 of 9
hey helg37, what is the "Prints" data type that's used in the generic container (concurrentQueue)? is that the quote argument dataType from iqFEED? also are GetPrint() and WorkerPrint() in the iqFEED quote event? and where is the worker_print thread started? i assuming it not started in the iqFEED quote event?
also I don't understand why youre locking the conconcurrentQueue object? doesn't the EventWaitHandle object synchronize your thread? Edited by d_allen on Jan 28, 2011 at 03:46 PM Edited by d_allen on Jan 28, 2011 at 03:47 PM
|
Helg37
-Interested User-
Posts: 6
Joined: Jan 4, 2011
|
Posted: Jan 29, 2011 12:45 AM
Msg. 7 of 9
Hello ! Do not quite understand your question, but issues of implementation of Data Feed processing in my humble opinion is a question a specific developer. I showed an example, one way of handling a strong Data Feed. Details are already on the accurate implementation of the code by yourself. I do not claim purity of the sample code, but this scheme really works for me. But the code sample may be not optimal.
|
d_allen
-Interested User-
Posts: 29
Joined: Nov 5, 2008
|
Posted: Jan 30, 2011 04:41 PM
Msg. 8 of 9
Edited by d_allen on Jan 30, 2011 at 04:44 PM
|
d_allen
-Interested User-
Posts: 29
Joined: Nov 5, 2008
|
Posted: Jan 30, 2011 04:41 PM
Msg. 9 of 9
hey Helg37 sorry if I came off like I was trying to critique your code, lol! I just don't understand what's going on and what I'm suppose to be doing :) I need to understand what's going on and "WHY". That way I'll know how to modify it to fit my own needs and also I'll be more knowledgeable about what's going on and what I'm doing. That's why I had so many questions.
I'm thankful that you replied and provided me with a solution, I'm just not clear on what's going on and how I'm suppose to use the example that you provided.
So please don't take my questions the wrong way, I'm just trying to learn and not just have you guys hold my hand and give me the answers...it's VERY important for me to understand what I'm doing.
:)
allen Edited by d_allen on Jan 30, 2011 at 04:47 PM Edited by d_allen on Jan 30, 2011 at 04:49 PM Edited by d_allen on Jan 30, 2011 at 04:49 PM
|