Threading question - ensure execution of a block of code

K

kpg

Is there a way to protect a section of code so that all the statements in
the protected block are executed without being interrupted by another
thread?

I have a worker thread that adds a value to an array (a circular buffer)
then increments the array index. If the user clicks on a button of a form
in the main thread, sometimes the main thread code will then access the
array after the value has been added, but before the array index has been
updated.

I know I've seen ways to protect code in other languages (Pascal or Ada I
think) but how can this be done in vb.net?

thanks,
kpg
 

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

Similar Threads


Top