"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
Now that VB is multithreaded, are there any critical sections?
Thanks
Every object has a Monitor which you can use to control concurrency. Only
one thread can enter a Monitor at a time.
VB has the SyncLock keyword to allow you to use a block of code to
enter/exit a Monitor.
Shared objects are shared among all object instances and threads, so any
shared object can be used like a critical section.
EG
class MyClass
public shared readonly SyncRoot as new Object()
public shared sub DoSomething()
SyncLock SyncRoot
'only one thread at a time in here
end SyncLock
end sub
end class