Prev: A few basic questions for a newb coming from VB6
Next: Outlook 2007--checking if a folder exists
From: kpg on 6 May 2010 01:45 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
From: Cor Ligthert[MVP] on 6 May 2010 01:55 Take a look at Synclock http://msdn.microsoft.com/en-us/library/3a86s51t(VS.71).aspx Success Cor "kpg" <no(a)way.com> wrote in message news:OFdye9N7KHA.3184(a)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 > >
|
Pages: 1 Prev: A few basic questions for a newb coming from VB6 Next: Outlook 2007--checking if a folder exists |