By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,010 Members | 2,774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,010 IT Pros & Developers. It's quick & easy.

C++/CLI Realtime Data intensive Application

P: n/a
Hello

I have created a realtime data intensive application in C++/CLI. Data
streams into this application through a set of ActiveX controls. For
example, each stock symbol will be assigned to one of these controls and
the symbol will be updated through one of the events of these controls.

Symbols and their corresponding data are displayed in a listview. Data
is updated few times a second per symbol.

Unfortunately I have encountered several problems:

1) CPU utilization of this app is quite high for a sustained period of
time. Utilization of up to 100% is often seen for close to a minute at
a time.

2) The ever nagging Listview flickering problem which is constant due to
the rapid data updates.

Below is the relevant fragment of code. Is the basic use of delegates
correct? Is there any way to avoid the flicker? BeginUpdate and
EndUpdate make the app unusable!

Any general or specific hint or help is greatly appreciated.

Regards

---------------------------------------

public ref class Form1 : public System::Windows::Forms::Form
{

private: delegate System::Void
UpdateListViewDelegate(System::Collections::Hashta ble ^map);

private: System::Void UpdateListView(System::String ^symbol,
System::Collections::Hashtable ^map)
{
if(listView1->InvokeRequired == false)
{
System::Windows::Forms::ListViewItem ^item =
listView1->FindItemWithText(symbol);

System::Collections::IEnumerator^ myEnum =
map->GetEnumerator();

while(myEnum->MoveNext())
{
System::Collections::DictionaryEntry ^de =
dynamic_cast<DictionaryEntry^>(myEnum->Current);

System::String ^key =
dynamic_cast<System::String^>(de->Key);
System::String ^value =

dynamic_cast<System::String^>(de->Value);

int index = FindColunmIndexDu(key);

item->SubItems[index]->Text = value;

item->SubItems[index]->BackColor = Color::Lime;

item->UseItemStyleForSubItems = false;
}
else
{
UpdateListViewDelegate ^UpdateLstDeleg =
gcnew UpdateListViewDelegate(this,
&Form1::UpdateListView);

this->BeginInvoke(UpdateLstDeleg,
gcnew cli::array<Object^>{symbol,map});
}
}
}

private: System::Void TRecordSet_DataChange(System::Object^ sender,
DataChangeEvent^ e)
{
TRecordSet ^obj = safe_cast<TRecordSet^>(sender);

System::Collections::Hashtable ^hash = gcnew
System::Collections::Hashtable();

hash->Add("Open", obj->GetOpenStr());
hash->Add("High", obj->GetHighStr());
...
...
...
UpdateListView(obj->GetSymbolStr(), hash);
}

}

}
Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.