Critical Sections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Now that VB is multithreaded, are there any critical sections?
Thanks
Mark
 
Mark said:
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
 
Mark said:
Now that VB is multithreaded, are there any critical sections?

Take a look at 'SyncLock' and the 'Monitor' class.
 
"Herfried K. Wagner [MVP]"
..
Take a look at 'SyncLock' and the 'Monitor' class.
Are you sure that that is all?

I think that I have to disagree with you about that.

Cor
 
When you read your message you can get the idea that you say that this are
the only critical things, I think that is not right, therefore just to
protect you a little bit.

The only thing you had to write was, no I did not mean that.

Cor
 
Cor Ligthert said:
When you read your message you can get the idea that you say that this are
the only critical things, I think that is not right, therefore just to
protect you a little bit.

"Critical section" is a term with a special meaning in the field of process
synchronization/"multithreading".
 

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