mutex and dll

2 views
Skip to first unread message

maxim...@hotmail.com

unread,
Nov 4, 2009, 11:26:33 PM11/4/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
hi everyone, here is my problem:
i have 2 programs accessing the same dll.
theres a function in the dll that i want to protext with a mutex (to
make the 2 programs cannot access that functions at the same time, but
1 after the other).
the mutex i put on the function not working, how can i do?
Thanks in advance

Jamie Fraser

unread,
Nov 5, 2009, 4:44:15 AM11/5/09
to dotnetde...@googlegroups.com
Care to provide a code sample?

Cerebrus

unread,
Nov 5, 2009, 4:46:29 AM11/5/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Show us some code, fella !

http://dotnetdevelopment.pastebin.com/

On Nov 5, 9:26 am, "maxime_p...@hotmail.com" <maxime_p...@hotmail.com>
wrote:

Xi Shen

unread,
Nov 6, 2009, 7:31:23 AM11/6/09
to dotnetde...@googlegroups.com
you want to put a mutex in your dll, hoping that mutex can control two
program while accessing it? dude, that is not possible ;)

because when your dll is loaded into you program, each will have an
instance of that mutex. actually i do not understand why you want to
protect your program from calling the same function at the same time.
when you program loads your dll, each program has an instance of your
dll. so the function your program calling at runtime is not the same
one.

one reason i can figure out why you want to do this is because the
function in your dll is trying to access some shared data, like a file
on the system. in this case, you should try to make sure your function
access your data one after the other, instead of trying to make sure
the function is called one after the other.

--
Best Regards,
David Shen

http://twitter.com/davidshen84/
http://meme.yahoo.com/davidshen84/

Reply all
Reply to author
Forward
0 new messages