Critical Sections of code

  • Thread starter Thread starter Sid Price
  • Start date Start date
S

Sid Price

I have a multi-threaded VB.NET application and I need to be able to access a
shared set of variables from multiple threads. In CE.NET there are objects
called critical section objects that a thread can acquire on entry to a
section manipulating such variables and release when done. Any other thread
trying to acquire the same object will suspend until the object is released.

Is there such a mechanism in VB.NET please?

Thanks,
Sid.
 
Its a bit difficult to describe it all here, but yes it does. Look up the
"Synclock" keyword on the net.
 
Sid Price said:
I have a multi-threaded VB.NET application and I need to be able to access
a shared set of variables from multiple threads. In CE.NET there are
objects called critical section objects that a thread can acquire on entry
to a section manipulating such variables and release when done. Any other
thread trying to acquire the same object will suspend until the object is
released.

Is there such a mechanism in VB.NET please?

Check out the 'SyncLock' statement and the .NET Framework's 'Monitor' class.
 

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

Back
Top