c# - Updating Winform ListView control by one event handler that may be fired from several threads -


I have a "Win Form" application that listens to an event that can be picked up with some different threads.

On that event, I want to update the "List View" control. Of course I might need to use an incognito but I have a question: should I use the lock on the function? Will not I update the "List View" control or not?

Be a pot that I am updating the list view as a single function and with the same event, but more than one thread can increase the same phenomenon.

Is it true that all events can be removed from all threads handled by the main thread so that they will be executed one by one?

Thank you.

If you think that the event can be removed from many threads at the same time, or If at least after the update is completed, then you should lock. / p>

Something like this:

  lock (myListView) {updateMyListView (); }   

Should be enough lock on the list view object will still allow you to edit it.

A word of warning, this will not keep other things from editing the list view, this is the only only code itself lock (myListView) block Pay attention to the lock.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -