atlantis
atlantis

Reputation: 837

Mutex across network - C#.NET

I have a message queue on a shared system. This queue is accessed by 2 processes which run on 2 other machines. I need to control access to this queue by the 2 processes. So I need a "network mutex". How can I achieve this?

I don't think this is supported out of the box in C#.NET but if I have missed something very obvious, do point me in the right direction. This question has been asked before but the solutions suggested involved a database. I dont have any database in question.

How To Mutex Across a Network?

Upvotes: 5

Views: 9053

Answers (3)

atlantis
atlantis

Reputation: 837

I think I found what I was looking for ... and it turns out to be a simple property setting!

http://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.denysharedreceive%28VS.80%29.aspx

Should have explored this first!!

Jeff key has reported an issue with this and his experience: http://weblogs.asp.net/jkey/archive/2004/05/12/130922.aspx

Thank you all for the help.

Upvotes: 1

Richard
Richard

Reputation: 109035

Use MSMQ or other queuing system design for use across a network.

Win32 has no cross machine synchronisation primitives like a muxtex, you might be able to build something from file locking, but you would just be re-inventing MSMQ.

Upvotes: 1

Will
Will

Reputation: 75635

You need a third process, which actually owns the queued items. The two workers each ask the third process for the next item, and it's this third process that polices access and acts as the lock.

Upvotes: 3

Related Questions