Posterous theme by Cory Watilo

Threading in C# - Basic Synchronization

Locking Constructs

Construct

Purpose

Cross-Process?

Speed

lock

Ensures just one thread can access a resource, or section of code.

no

fast

Mutex

Ensures just one thread can access a resource, or section of code.
Can be used to prevent multiple instances of an application from starting.

yes

moderate

Semaphore

Ensures not more than a specified number of threads can access a resource, or section of code.

yes

moderate

Posted by

| Viewed
times