Many objects updating listview

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
 
C

Cor Ligthert

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
 

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