Solved

Synchronization between applications

Posted on 1998-06-12
8
197 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

8 Experts available now in Live!

Get 1:1 Help Now