Many objects updating listview

  • Thread starter Thread starter Kejpa
  • Start date Start date
K

Kejpa

Hi,
I've got a number of objects that each have it's own thread. When the value
changes I raise an event. Now, I want to handle the event in a form and show
the value in a listview.
With my first approach I had to have a synclock on the listview the whole
event handler, after some reading I've understood that updating a control
from different threads should use the controls Invoke statement.
Should I use it as well? It's not the individual thread that is updating the
control, at least that's what the major part of me is voting for ;)

TIA
/Kejpa
 
Kejpa,

Try to upgrade your listview from one place (the mainthread) giving the
information through events to that from the subthreads, than you need no
synclock at all.

However use the standard method to catch that event from threads for that.

See for that the walkthrough authorising a multithreading application. It is
a terrible written sample because of the names of fields and methods they
have used, however it shows in the bottom very well how to handle an event
in a multithreading situation.

http://msdn.microsoft.com/library/d...onwalkthroughsimplemultithreadedcomponent.asp

I hope this helps?

Cor
 
Back
Top