[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Another trouble with my thesis! (Using Of Mutex Structure

Leonardo Lanni

8/24/2003 2:30:00 PM

Hello!
I just want to thank for the answer to my previous question, you've been
very kind to me, I just have another question for you!
I've still my 2 processes, the first installs shared memory and a mutex, the
second opens both and has the purpose to create and manage a collection of
messages written into the shared memory. So by the second process I'm able
to add,remove a message or view the all into the shared memory, into a LIFO
structure.
I need a mutex in order to avoid data inconsistence in the shared memory if
2 or more instances of the program are working, so that every function (add,
remove, view) makes WaitForSingleObject on the mutex immediately before
operating on shared memory,and makes a ReleaseMutex when it finishes to work
on it.
In installing Mutex (1st program) I used : sem1 =
CreateMutex(0,FALSE,"leo");
In opening Mutex (2nd program) I used : sem =
OpenMutex(MUTEX_ALL_ACCESS,FALSE,"leo");
The problem is this : Sometimes in using Add/Remove/View function, the
process blocks as if the mutex was 0 (but of course it is initially set on
1), and there is no way to unblock it, but closing both the processes (1st
and 2nd) and restarting both..
I thought the problem was in choosing the desidered access mode:
MSDN suggested to use MUTEX_MODIFY_STATE if I need to use ReleaseMutex (as
my case),
but using it the mutex does not work at all..(opening 2 instances there is
no block on function is mutex is on 0)
While using MUTEX_ALL_ACCESS the mutex works correctly but I obtain the
problem shown before.
I've also thought it depends on the BOOL regulates the inherit of to process
created by this one, that I've set on FALSE.
Please help me in this and I'm ready with my programm!
Thank you again,
Leonardo