C# and Mutexes (Muteces?)

14 11 2006

I’m new to getting multi-threading working in C#, so I’m looking for some help with Mutexes.

I have code that looks like the following:

Mutex MyMutex = new Mutex();

Then later in parts that I want to make sure work at separate times:

void Part1()
{//Do Stuff}
void Part2()
//Do other stuff
//that must be not at the same
//time as Part1

Is this the correct way to make sure that these two methods (which get called via various triggers) don’t run while the other is running?  Comments and help appreciated.

2006-11-15 Update…  Figured out the problem.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: