Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Synchronization between applications

Posted on 1998-06-12
8
200 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 96
centeredAverage challenge 8 178
matchUp  challenge 6 68
Annoying "thing" blocks my view 4 113
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

765 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