Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Semaphore

Status
Not open for further replies.

raghu75

Programmer
Nov 21, 2000
66
0
0
IN
Hi,
I want to use semaphore to protect my resource using C#.Is there any help/place/code which can do this?

rgds,
raghu
 
.NET doesn't have semaphores, but it does offer a couple of objects which can do what you want.

The Interlocked class synchronizes access to a protected variable atomically. Meaning that it's Increment & Decrement methods can't be interrupted by another thread.

The Monitor class acts like a critical section, protecting access to a block of code so that only one thread at a time can execute it.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top