Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rajat - 28 Feb 2007 07:18 GMT
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.
rajat_tandon2000@yahoo.com.
Ciaran O''Donnell - 28 Feb 2007 09:01 GMT
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

Signature

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

> Hi,
>
[quoted text clipped - 45 lines]
> Rajat Tandon.
> rajat_tandon2000@yahoo.com.
Rajat - 28 Feb 2007 15:01 GMT
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.

>I would suggest removing the databinding and code up the displaying to the
>UI
[quoted text clipped - 66 lines]
>> Rajat Tandon.
>> rajat_tandon2000@yahoo.com.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.