R
Rajat
Hi,
I could not get the answer on the Performance community hence forwarding the
same issue here...
I am using a third party COM component to get very very fast data stream. I
have dragged the com component on a windows form. Now we can request the
data for specific symbols on this com component and in turn it will start
pouring in data in form of
continuous events for the requested symbols. The problem is that data stream
is too fast and can easily make the CPU go to 100%.
The tricks which I am thinking to tackle the issue are ...
1) Instantiate the com component form on the new thread and put the data in
alternate generic dictionaries (We have 2 side by side dictionaries. One
dictionary start filling with data then other dictionary is being accessed
by the consumer module) . So a dedicated thread of consumer class with poll
in the alternated dictionary after a certain time interval, set the flag on
1 dictionary and start copying the data from alternated dictionary to
another datastructure BindableDictionary(It is a wrapper arround 2 data
structures - 1 BindingList<> and 1 Dictionary<>. As the name suggest, as
soon as the consumer module copies data in BindableDictionary, it start
displaying it on UI.)
[STAThread]
private void InstantiateCOMComponent(object state)
{
_comManager = comComponentForm.GetInstance();
Application.Run(new comComponentForm());
_comManager.Visible = false;
}
but as soon as we try to instantiate the COM component on the new thread, it
gives the error -
Message "ActiveX control '7b0deade-e17b-11d2-93e6-00a0c91827c9' cannot be
instantiated because the current thread is not in a single-threaded
apartment."
2) Because of the com component error, Another alternative could be to apply
the com component on a windows form in a new exe and make it a server. Then
supply data through sockets to clients.
Please suggest/comment about the alternatives given above or any better way
of solving the business problem. I appreciate you reading a long email.
Thanks & Regards,
Rajat Tandon.
(e-mail address removed).
I could not get the answer on the Performance community hence forwarding the
same issue here...
I am using a third party COM component to get very very fast data stream. I
have dragged the com component on a windows form. Now we can request the
data for specific symbols on this com component and in turn it will start
pouring in data in form of
continuous events for the requested symbols. The problem is that data stream
is too fast and can easily make the CPU go to 100%.
The tricks which I am thinking to tackle the issue are ...
1) Instantiate the com component form on the new thread and put the data in
alternate generic dictionaries (We have 2 side by side dictionaries. One
dictionary start filling with data then other dictionary is being accessed
by the consumer module) . So a dedicated thread of consumer class with poll
in the alternated dictionary after a certain time interval, set the flag on
1 dictionary and start copying the data from alternated dictionary to
another datastructure BindableDictionary(It is a wrapper arround 2 data
structures - 1 BindingList<> and 1 Dictionary<>. As the name suggest, as
soon as the consumer module copies data in BindableDictionary, it start
displaying it on UI.)
[STAThread]
private void InstantiateCOMComponent(object state)
{
_comManager = comComponentForm.GetInstance();
Application.Run(new comComponentForm());
_comManager.Visible = false;
}
but as soon as we try to instantiate the COM component on the new thread, it
gives the error -
Message "ActiveX control '7b0deade-e17b-11d2-93e6-00a0c91827c9' cannot be
instantiated because the current thread is not in a single-threaded
apartment."
2) Because of the com component error, Another alternative could be to apply
the com component on a windows form in a new exe and make it a server. Then
supply data through sockets to clients.
Please suggest/comment about the alternatives given above or any better way
of solving the business problem. I appreciate you reading a long email.
Thanks & Regards,
Rajat Tandon.
(e-mail address removed).