C++/CLI Realtime Data intensive Application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • none

    #1

    C++/CLI Realtime Data intensive Application

    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
    UpdateListViewD elegate(System: :Collections::H ashtable ^map);

    private: System::Void UpdateListView( System::String ^symbol,
    System::Collect ions::Hashtable ^map)
    {
    if(listView1->InvokeRequir ed == false)
    {
    System::Windows ::Forms::ListVi ewItem ^item =
    listView1->FindItemWithTe xt(symbol);

    System::Collect ions::IEnumerat or^ myEnum =
    map->GetEnumerator( );

    while(myEnum->MoveNext())
    {
    System::Collect ions::Dictionar yEntry ^de =
    dynamic_cast<Di ctionaryEntry^> (myEnum->Current);

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

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

    int index = FindColunmIndex Du(key);

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

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

    item->UseItemStyleFo rSubItems = false;
    }
    else
    {
    UpdateListViewD elegate ^UpdateLstDeleg =
    gcnew UpdateListViewD elegate(this,
    &Form1::UpdateL istView);

    this->BeginInvoke(Up dateLstDeleg,
    gcnew cli::array<Obje ct^>{symbol,map });
    }
    }
    }

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

    System::Collect ions::Hashtable ^hash = gcnew
    System::Collect ions::Hashtable ();

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


    }

    }



    }
Working...