0

I have some resource that is shared between various .net application.

If one app is using that resource then other apps should wait untill first app release that. Other apps will get chance to occupy that resource randomly based upon cpu scheduling.

I was trying to use mutex for this but if an application has occupied the mutex and terminates abnormally then other apps get error.

Please suggest a design to resolve this scenario.

Romil Kumar Jain
  • 20,239
  • 9
  • 63
  • 92
  • Sorry dude, you got the right approach but totally failed to debug. Mutexes ARE released..... when you program properly. The OS is not written by juniors. At least not that part. I suggest you fix your bug. – TomTom Nov 19 '14 at 13:17
  • @TomTom, It will be very nice if you can give me some design. I found the code on many sites but I am finding the implementation of waitOne and releasemutex difficult. If any lock is put wrong then there will be deadlock situation. – Romil Kumar Jain Nov 19 '14 at 13:22
  • There is no generic design - this is one of the things you likely have to put up step by step. And it depends what you actually do there. The link I put in a duplicate deals with the problem. And I fear design suggestions are too broad for here. This is a Q&A site, not a "do consulting free". A design for your problem depends on a lot of exact details and can easily be a 20 page document. – TomTom Nov 19 '14 at 13:23

2 Answers2

1

Mutex is the right thing to use. Maybe this or this would help you with application terminating abnormally holding mutex (google abandoned mutex)?

Community
  • 1
  • 1
Pavel Krymets
  • 6,253
  • 1
  • 22
  • 35
-2

Google for Named Pipes. I think it's a safer approach for you.