PC Review


Reply
Thread Tools Rate Thread

Threading question - ensure execution of a block of code

 
 
kpg
Guest
Posts: n/a
 
      6th May 2010
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


 
Reply With Quote
 
 
 
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      6th May 2010
Take a look at Synclock

http://msdn.microsoft.com/en-us/library/3a86s51t(VS.71).aspx

Success

Cor

"kpg" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to ensure sequential command execution via SQL Query tables? =?Utf-8?B?SGFrYW4gS29ya3V0?= Microsoft Excel Programming 1 30th Oct 2007 07:04 AM
Execution of asynchronous code is not supported in Windows Forms threading model Carly Microsoft VB .NET 0 21st Dec 2006 08:08 PM
code runs well on 3rd execution after getting Error: 3021 on 1st 2 execution =?Utf-8?B?eWFubg==?= Microsoft Access VBA Modules 0 23rd Mar 2004 11:01 AM
Ensure Application Path is unchanged during execution in Access VBA =?Utf-8?B?U3VubnkgT2tvcmll?= Microsoft Access VBA Modules 1 15th Jan 2004 10:32 PM
multi-threading and code execution problems Chris LaJoie Microsoft C# .NET 1 29th Jul 2003 11:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:37 AM.