VB.NET thread synchronization of class property -


i have question thread synchronization in vb.net.

suppose have list object private class member , expose read-only property (notice synchronization in get block):

dim mysubmissionlist new list(of submission)  readonly property submissionlist() list(of submission)       synclock mysubmissionlist       return mysubmissionlist     end synclock   end end property 

in method in class, list added to:

public sub addsubmission(byref submsn submission)   synclock mysubmissionlist     mysubmissionlist.add(submsn)   end synclock end sub 

now, suppose use property in class such:

' currentsubmissions object of class discussed above each submsn in currentsubmissions.submissionlist   ' use submsn here... next 

my question is, mysubmissionlist synchronized whole for block? basically, wouldn't want mysubmissionlist used addsubmission until other class done iterating.

this not design. list class not thread safe , there no const concept there in c++ user of thread attempt add list. simple solution use 1 of thread safe collections blockingcollection. if not suite provide own custom class custom enumerator observes lock.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

java - Using an Integer ArrayList in Android -