|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Threading question - ensure execution of a block of codeIs 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 Take a look at Synclock
http://msdn.microsoft.com/en-us/library/3a86s51t(VS.71).aspx Success Cor Show quoteHide quote "kpg" <n*@way.com> wrote in message news:OFdye9N7KHA.3184@TK2MSFTNGP05.phx.gbl... > 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 > >
A few basic questions for a newb coming from VB6
Add image over other images Microsoft Responds to the Evolution of Online Communities Microsoft Responds to the Evolution of Online Communities Microsoft Responds to the Evolution of Online Communities Registry Access Byte Array Question How to stop a form being 'non maximised' Help in grouping dataset with Linq FTP over SSL |
|||||||||||||||||||||||