C++/CLI Realtime Data intensive Application

N

none

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::Hashtable ^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);


}

}



}
 

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

Top