Solved

Synchronization between applications

Posted on 1998-06-12
8
198 Views
Last Modified: 2013-11-20
I have a DLL which is being used by 2 applications. I want to synchronize the accesing of the DLL using a mutex. I
I used a CMutex object and used CSingleLock to lock and unlock the resource(DLL). It is working in the same apllication. But across applications the DLL is not getting locked. I want to know what is the reason and solution for this. Kindly help me. Is it not possible thro mutexes? Can I know that process of putting the applications in OLE out-of-process server and Yonat suggested to me?
Chensu: I have given the object name for the mutex.
The code construct is as follows:
CMutex mutObj; //in global scope
//inside my resource
CSingleLock singleLock(&mutObj);
singleLock.Lock();
{
;;;;
}
singleLock.Unlock();
The exclusion is taking place within the appln but not across the applns.

0
Comment
Question by:aac
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:yonat
ID: 1317891
I think that each application loads a seperate instance of the DLL into it's own process space.

To have the same objects shared by to processes (applications), you will need to put them in an OLE out-of-process server.
0
 

Author Comment

by:aac
ID: 1317892
Edited text of question
0
 

Author Comment

by:aac
ID: 1317893
Edited text of question
0
 
LVL 23

Expert Comment

by:chensu
ID: 1317894
I think the CMutex object can be used across process boundaries. But you must specify the name of the CMutex object. Do you specify a name when you construct the object?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:aac
ID: 1317895
Edited text of question
0
 
LVL 23

Expert Comment

by:chensu
ID: 1317896
No, you haven't given a name for the mutex. It is not the C++ object name. Use the following code.

CMutex mutObj(FALSE, _T("MyMutex"));

mutObj will reference the mutex "MyMutex". If you don't give it a name, it will create a new mutex, in which case you have two seperated mutex objects created in two processes.
0
 

Author Comment

by:aac
ID: 1317897
Chensu's answer worked out!!! Hats off to Chensu. Thank U very much for prompt answers.
0
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1317898
So, why did you reject my answer instead of giving me A? :-(
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now