How to improve performance for stock exchange data display received from third party com component

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).
 
G

Guest

I would suggest removing the databinding and code up the displaying to the UI
if you can. Databinding is really expensive comparativly as it uses
reflection and refreshes the data a lot more than is necessary.
Also for creating the thread to run the COM component on, you probably need
to create the thread, set the appartment state to AppartmentState.STA

HTH
 
R

Rajat

Hi,

Thanks for the suggestions. By removing the databinding I understand that I
need to take any container which don't refresh the UI automatically (e.g. -
As BindingList<> does and DataTable don't). Even in case of DataTable, we
will give the datasource of the Grid as DataTable.

Also, what if third party has not designed the COM component in such a way
to use from different thread?

In the meanwhile I will implement the same and will post further queries if
any.

Regards,
Rajat.


Ciaran O''Donnell said:
I would suggest removing the databinding and code up the displaying to the
UI
if you can. Databinding is really expensive comparativly as it uses
reflection and refreshes the data a lot more than is necessary.
Also for creating the thread to run the COM component on, you probably
need
to create the thread, set the appartment state to AppartmentState.STA

HTH

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com


Rajat said:
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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top