Multithreading newbie question

D

Daniel

Hi,
I've developed multithreading applications with Java in the past and
want to know if VB.Net or C# has this ability? In Java, the "synchronized"
keyword was used to ensure that only one thread can execute the function at
a time, is there an equivalent in .NET?

Thanks,
Dan
 
T

TJoker .NET [MVP]

You can use the lock (C#) or SyncLock (VB) to syncronize any given object in
your code:

private object someObj = new object;
private void f1()
{
lock(someObj)
{
//do your stuff here
}
}
 
T

Tom Spink

Hi, you can lock an object using the SyncLock keyword:

....
SyncLock MyObject
 
D

Dick Grier

Hi,

SyncLock and Monitor provide this ability.

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
 

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

Top